I would like to map a drive withing a VB6 application.
For example:
Private Sub cmdONE_Click()
'MAP A SERVER PATH TO THE I:/ DRIVE
End Sub
Private Sub CmdTWO_Click()
'MAP ANOTHER SERVER TO DRIVE I:/
End sub
Printable View
I would like to map a drive withing a VB6 application.
For example:
Private Sub cmdONE_Click()
'MAP A SERVER PATH TO THE I:/ DRIVE
End Sub
Private Sub CmdTWO_Click()
'MAP ANOTHER SERVER TO DRIVE I:/
End sub
www.mvps.org/vbnet have some great networking samples
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)