VB Code:
  1. Private Declare Function WNetAddConnection Lib "mpr.dll" Alias "WNetAddConnectionA" (ByVal lpszNetPath As String, ByVal lpszPassword As String, ByVal lpszLocalName As String) As Long
  2. Private Declare Function WNetCancelConnection Lib "mpr.dll" Alias "WNetCancelConnectionA" (ByVal lpszName As String, ByVal bForce As Long) As Long
  3. Const WN_SUCCESS = 0 ' The function was successful.
  4. Const WN_NET_ERROR = 2 ' An error occurred on the network.
  5. Const WN_BAD_PASSWORD = 6 ' The password was invalid.
  6. Function AddConnection(MyShareName As String, MyPWD As String, UseLetter As String) As Integer
  7.     On Local Error GoTo AddConnection_Err
  8.     AddConnection = WNetAddConnection(MyShareName, MyPWD, UseLetter)
  9. AddConnection_End:
  10.     Exit Function
  11. AddConnection_Err:
  12.     AddConnection = Err
  13.     MsgBox Error$
  14.     Resume AddConnection_End
  15. End Function
  16. Function CancelConnection(DriveLetter As String, Force As Integer) As Integer
  17.     On Local Error GoTo CancelConnection_Err
  18.     CancelConnection = WNetCancelConnection(DriveLetter, Force)
  19. CancelConnection_End:
  20.     Exit Function
  21. CancelConnection_Err:
  22.     CancelConnection = Err
  23.     MsgBox Error$
  24.     Resume CancelConnection_End
  25. End Function
  26. Private Sub Form_Load()
  27.     'KPD-Team 1999
  28.     'URL: [url]http://www.allapi.net/[/url]
  29.     'E-Mail: [email][email protected][/email]
  30.  
  31.     'to add a connection call by:
  32.     variable = AddConnection(, , )
  33.     'To cancel a connection type:
  34.     varible = CancelConnection()
  35. End Sub

Hai i would like to ask how do i used this code?? I've got it from http://www.mentalis.org/apilist/WNet...nnection.shtml

It suppose to disconnect or connect the internet connection of a computer. But i can't get it to function. Can someone help me with this?? Please help...