CodeItBetter Programming Another VB Programming Blog

How to Disconnect Network Drive

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'Network - How to Disconnect Network Drive
Option Explicit
 
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal _
    lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
 
Public Function DisconnectIt(ByVal sDriveLetter As String, _
    Optional ByVal bDisconnectOpenFiles As Boolean = True)
'Inputs  - sDriveLetter - Drive letter which needs to be disconnected
'          bDisconnectOpenFiles - whether to disconnect the drive if there are files open on it.
'                               - True  - disconnect the drive if there are files opened
'                               - False - not to disconnect the drive if the files are opened
'Returns - True  - if Drive is disconnected
'          False - if Drive is not disconnected
'Usage   - MsgBox DisconnectIt("Q:", True)
    DisconnectIt = WNetCancelConnection(sDriveLetter, bDisconnectOpenFiles)
End Function
Filed under: Network Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.