VB Code:
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
'Description
'Here \\vdk00005\proj is the name of the network path
'H: is the Drive Letter
'Map Network Drive (Connect)
WNetAddConnection "\\vdk00005\proj", "", "H:"
Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Private DisconnectIt As Long
'Where H: is the drive letter you wish to connect
'The second parameter of this API determines whether to disconnect the drive if
'there are files open on it. If it is passed FALSE, the disconnect will fail if there are open files
'If it is passed TRUE, the disconnect will occur no matter what is open on the drive
DisconnectIt = WNetCancelConnection("H:", True)
'Map Network Drive (DisConnect)