Important alert: (current site time 7/16/2013 4:08:15 AM EDT)
 

VB icon

Connect, Disconnect Networks Drives ( EASILY )

Email
Submitted on: 6/27/1999
By: MASTER VB PROGRAMMER 
Level: Not Given
User Rating: By 101 Users
Compatibility: VB 5.0, VB 6.0
Views: 37712
 
     Connects and Disconnects Network Drives from your System
 

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'**************************************
'Windows API/Global Declarations for :Connect, Disconnect Networks Drives ( EASILY )
'**************************************
Declare Function WNetConnectionDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Declare Function WNetDisconnectDialog Lib "mpr.dll" (ByVal hwnd As Long, ByVal dwType As Long) As Long
Public Const RESOURCETYPE_DISK = &H1
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
  1. You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.
				
'**************************************
' Name: Connect, Disconnect Networks Drives ( EASILY )
' Description:Connects and Disconnects Network Drives from your System
' By: MASTER VB PROGRAMMER
'
'This code is copyrighted and has' limited warranties.Please see http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=2209&lngWId=1'for details.'**************************************

Private Sub cmdConnect_Click()
Dim x As Long
If Index = 0 Then
x = WNetConnectionDialog(Me.hwnd, RESOURCETYPE_DISK)
End If
End Sub
Private Sub cmdDisconnect_Click()
If Index = 1 Then
x = WNetDisconnectDialog(Me.hwnd, RESOURCETYPE_DISK)
End If
End Sub


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

6/27/1999 8:43:00 PMBrenda

This is very kewl programming!
(If this comment was disrespectful, please report it.)

 
6/28/1999 7:01:00 PMHelgi Rudd

Works well... right on!
(If this comment was disrespectful, please report it.)

 
7/5/1999 1:44:00 AMConrad

Not bad, simple but very usefull
Thanxs
(If this comment was disrespectful, please report it.)

 
7/5/1999 1:53:00 AMConrad

Me again,
Question : Is there a way of connecting a drive without prompting the user??

Thanxs
(If this comment was disrespectful, please report it.)

 
7/6/1999 8:29:00 AMNick

Easy, instead of putting the code:

Private Sub cmdConnect_Click()
Dim x As Long
If Index = 0 Then
x = WNetConnectionDialog(Me.hwnd, RESOURCETYPE_DISK)
End If
End Sub

****************Put***************

Private Sub Form_Load()
Dim x As Long
If Index = 0 Then
x = WNetConnectionDialog(Me.hwnd, RESOURCETYPE_DISK)
End If
End Sub
(If this comment was disrespectful, please report it.)

 
7/6/1999 6:53:00 PMSlimFlem

The API calls are good. However, if you could post code that was complete and accurate, it would be nice. The command buttons are not control arrays in the sample code and variable x is not declared for disconnect. You might want to change your name to something else.
(If this comment was disrespectful, please report it.)

 
7/9/1999 10:18:00 PMAaron

this wont work for me. The

Public Const RESOURCETYPE_DISK = &H1 turns red and gives me an error
(If this comment was disrespectful, please report it.)

 
7/16/1999 5:37:00 PMMo

If you need to know how to connect the drive without the resulting error msg for the user then e-mail me & I will send u my simple project. It works !
(If this comment was disrespectful, please report it.)

 
7/17/1999 9:51:00 AMTenox

This looks great, but does it automatically
find the next available drive letter? Either way,
is there a way to find next avail drive independently?
Thanks, /ts
(If this comment was disrespectful, please report it.)

 
7/26/1999 12:23:00 PMGilad Shulkin

Aaron, you should put

Public Const RESOURCETYPE_DISK = &H1

into separate module (actually it always a good idea to take constants out of the form code). Good Luck
(If this comment was disrespectful, please report it.)

 
7/27/1999 8:18:00 AMNana

Work nice but one question is there any way in VB that we can right the script to change the CDROM drive and than restart the computer. If u know something like that Please e-mail me

Thank YOu

(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.