G
Guest
Hi,
when i call the NETUserChangePassword from the netapi32.ll I receive "Module
not found" error?
Here my code:
Private Declare Unicode Function NetUserChangePassword Lib
"netapi32.dll" (ByVal domainname As String, _
ByVal
Username As String, _
ByVal
OldPassword As String, _
ByVal
NewPassword As String) As Long
Sub main
retVal = netUserChangePassword("MyDomain", "MyUser", "OldPassword",
"NewPassword")
End sub
Public Shared Function GetErrorMessage(ByVal errorCode As Integer) As String
Dim FORMAT_MESSAGE_ALLOCATE_BUFFER As Integer = &H100
Dim FORMAT_MESSAGE_IGNORE_INSERTS As Integer = &H200
Dim FORMAT_MESSAGE_FROM_SYSTEM As Integer = &H1000
Dim messageSize As Integer = 255
Dim lpMsgBuf As String
Dim dwFlags As Integer = FORMAT_MESSAGE_ALLOCATE_BUFFER Or
FORMAT_MESSAGE_FROM_SYSTEM Or FORMAT_MESSAGE_IGNORE_INSERTS
Dim ptrlpSource As IntPtr = IntPtr.Zero
Dim prtArguments As IntPtr = IntPtr.Zero
Dim retVal As Integer = FormatMessage(dwFlags, ptrlpSource,
errorCode, 0, lpMsgBuf, _
messageSize, prtArguments)
If 0 = retVal Then
Throw New Exception("Failed to format message for error code " +
errorCode.ToString() + ". ")
End If
Return lpMsgBuf
End Function 'GetErrorMessage
when i call the NETUserChangePassword from the netapi32.ll I receive "Module
not found" error?
Here my code:
Private Declare Unicode Function NetUserChangePassword Lib
"netapi32.dll" (ByVal domainname As String, _
ByVal
Username As String, _
ByVal
OldPassword As String, _
ByVal
NewPassword As String) As Long
Sub main
retVal = netUserChangePassword("MyDomain", "MyUser", "OldPassword",
"NewPassword")
End sub
Public Shared Function GetErrorMessage(ByVal errorCode As Integer) As String
Dim FORMAT_MESSAGE_ALLOCATE_BUFFER As Integer = &H100
Dim FORMAT_MESSAGE_IGNORE_INSERTS As Integer = &H200
Dim FORMAT_MESSAGE_FROM_SYSTEM As Integer = &H1000
Dim messageSize As Integer = 255
Dim lpMsgBuf As String
Dim dwFlags As Integer = FORMAT_MESSAGE_ALLOCATE_BUFFER Or
FORMAT_MESSAGE_FROM_SYSTEM Or FORMAT_MESSAGE_IGNORE_INSERTS
Dim ptrlpSource As IntPtr = IntPtr.Zero
Dim prtArguments As IntPtr = IntPtr.Zero
Dim retVal As Integer = FormatMessage(dwFlags, ptrlpSource,
errorCode, 0, lpMsgBuf, _
messageSize, prtArguments)
If 0 = retVal Then
Throw New Exception("Failed to format message for error code " +
errorCode.ToString() + ". ")
End If
Return lpMsgBuf
End Function 'GetErrorMessage