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

Related posts:

  1. How to Connect Network Drive
  2. How to Set Volume Name for given Drive letter
  3. How to List Network Computers
  4. How to use Net send to send message from one system to another system in Windows Network.
  5. How to Get the list of all SQL Servers in the Network
  6. How to Enumerate user accounts on network
  7. Get Time and Date of a Network machine Server or Workstation
  8. How to Return Volume Name for given Drive letter
  9. How to determine free disk drive space over network?
  10. How to return the drive type

Filed under: Network Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.