Declare Integer CloseHandle In Kernel32 Integer hObject Declare Integer GetLastError In Kernel32 Declare Integer FormatMessage In Kernel32 Integer dwFlags , ; String lpSource , ; Integer dwMessageId , ; Integer dwLanguageId , ; String @lpBuffer , ; Integer nSize , ; Integer Arguments #Define FORMAT_MESSAGE_FROM_SYSTEM 4096 Declare Integer LogonUser In advapi32 String lpszUsername,; String lpszDomain,; String lpszPassword,; Integer dwLogonType,; Integer dwLogonProvider,; Integer @phToken * dwLogonProvider: #Define LOGON32_PROVIDER_DEFAULT 0 #Define LOGON32_PROVIDER_WINNT50 3 #Define LOGON32_PROVIDER_WINNT40 2 #Define LOGON32_PROVIDER_WINNT35 1 * dwLogonType: #Define LOGON32_LOGON_INTERACTIVE 2 #Define LOGON32_LOGON_NETWORK 3 #Define LOGON32_LOGON_BATCH 4 #Define LOGON32_LOGON_SERVICE 5 cUserId = "myuserid" cPassword = "mypassword" cDomain = "mydomain" nToken = 0 nHandle = LogonUser (cUserId , ; cDomain , ; cPassword , ; LOGON32_LOGON_INTERACTIVE, ; LOGON32_PROVIDER_DEFAULT , ; @nToken) If nHandle > 0 MessageBox ("Password is correct!") CloseHandle (nToken) else nLastError = GetLastError () cMessageText = Space (256) nRetCode = FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM, ; 0 , ; nLastError , ; 0 , ; @cMessageText , ; 256 , ; 0) MessageBox (cMessageText) endifWhere it was added the declarations of CloseHandle, GetLastError and FormatMessage, the passing of nToken by reference (@nToken) and the closing of the token that represents the specified user, issuing a CloseHandle (nToken). Also when LogonUser fails GetLastError and FormatMessage are called to show wich error has occurred.