WNETAddConnection2 Error Codes.
Hello community
I am trying to decipher how to translate my error code i get when trying to connect. my error is 1168
I have read over the getLastError method but i obviously dont know how to use it.
here is an example of how i tried,
Code:
Public Function MapDrive(ByVal DriveLetter As String, ByVal UNCPath As String, ByVal uName As String, ByVal pWord As String) As Boolean
Dim nr As NETRESOURCE
Dim strUsername As String
Dim strPassword As String
nr = New NETRESOURCE
nr.lpRemoteName = UNCPath
nr.lpLocalName = DriveLetter & ":"
nr.dwType = RESOURCETYPE_DISK
strUsername = uName
strPassword = pWord
Dim result As Integer
Try
result = WNetAddConnection2(nr, strPassword, strUsername, 0)
Catch ex As Exception
MessageBox.Show("error: " & vbCrLf & ex.Message.ToString)
End Try
If result = 0 Then
MessageBox.Show(result)
Return True
Else
MessageBox.Show(errmsg = GetLastError(result))
Return False
End If
End Function
Any advice would be most helpfull including a simple code example on how to pass the error value to the method.