Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WNetCancelConnection2 return code question

Status
Not open for further replies.

jadams0173

Technical User
Feb 18, 2005
1,210
Im using vb 2005 and have a question about the return code I'm getting from WNetCancelConnection2.
I am getting a huge numbers like 1244963895005677770 and 1239615827498500096

It is disconnecting my network share as I expect but why the weird return results?

Code:
    Private Declare Function WNetCancelConnection2 Lib "mpr.dll" _
       Alias "WNetCancelConnection2A" _
      (ByVal lpName As String, _
       ByVal dwFlags As Long, _
       ByVal fForce As Long) As Long

Code:
Public Function DisconnectNetDrive(ByVal sResource As String, ByVal Force As Boolean) As Boolean

            'connection to the specified drive.
        'ErrInfo=NO_ERROR if sucessful

        Dim errInfo As Long
        errInfo = WNetCancelConnection2(sResource, 0, 1)

        If errInfo <> NO_ERROR Then
            WnetError(errInfo)
        End If
        DisconnectNetDrive = errInfo = NO_ERROR

    End Function
    Private Function WnetError(ByVal Errcode As Long) As String

        Select Case Errcode
            Case WN_Not_Supported
                WnetError = "Function is not supported."
            Case WN_Out_Of_Memory
                WnetError = "Out of Memory."
            Case WN_Net_Error
                WnetError = "An error occurred on the network."
            Case WN_Bad_Pointer
                WnetError = "The Pointer was Invalid."
            Case WN_Bad_NetName
                WnetError = "Invalid Network Resource Name."
            Case WN_Bad_Password
                WnetError = "The Password was Invalid."
            Case WN_Bad_Localname
                WnetError = "The local device name was invalid."
            Case WN_Access_Denied
                WnetError = "A security violation occurred."
            Case WN_Already_Connected
                WnetError = "The local device was connected to a remote resource."
            Case Else
                WnetError = "Unrecognized Error " + Str(Errcode) + "."
        End Select
    End Function
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top