Make your own free website on

[an error occurred while processing this directive]
Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
Const WN_SUCCESS = 0 ' The function was successful.
Const WN_NET_ERROR = 2 ' An error occurred on the network.
Const WN_BAD_PASSWORD = 6 ' The password was invalid.
Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As String) As Integer
    On Local Error GoTo AddConnection_Err
    AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
    Exit Function
    AddConnection = Err
    MsgBox Error$
    Resume AddConnection_End
End Function
Function CancelConnection(DriveLetter As String, Force As Integer) As Integer
    On Local Error GoTo CancelConnection_Err
    CancelConnection = WNetCancelConnection(DriveLetter, Force)
    Exit Function
    CancelConnection = Err
    MsgBox Error$
    Resume CancelConnection_End
End Function
Private Sub Form_Load()
    'KPD-Team 1999
    'to add a connection call by:
    variable = AddConnection(, , )
    'To cancel a connection type:
    varible = CancelConnection()
End Sub

Copyright © 1998-2000, The KPD-Team.
Send mail to with comments about this web site.
This site is located at