Jump to content

dllcall passed parameter problem


Recommended Posts

Hello -

I am passing several parameters to a DLL successfully, except for one parameter apparently. When I look at the results of what was passed via DllCall there is an extra, leading "1" on one of the parameters. How do I fix this?

The $ShutDownWindowTimeout variable is set to "800". When I display the parameters used in DllCall via a messagebox the parameter shows "1800" was passed instead. No matter what number I use it has a 1 leading it. Strange...

#include <WinAPI.au3>
$ShutDownWindowTimeout=800
$UserActionMessage = "SHUTDOWN"
$pTitle = DllStructCreate("char Title[32]")
$pMessage = DllStructCreate("char Message[128]")
$pResponse = DllStructCreate("DWORD Response")
$KernelCall = DllOpen(@SystemDir & "\Kernel32.dll")
$SessionId = DllCall($KernelCall, "DWORD", "WTSGetActiveConsoleSessionId")
DllClose($KernelCall)
DllStructSetData($pTitle, "Title", "Scheduled Power Action")
DllStructSetData($pMessage, "Message", "Your computer is scheduled to " & $UserActionMessage & ". Click CANCEL to keep working.")
$wtsapiCall = DllOpen(@SystemDir & "\Wtsapi32.dll")
$SendMessageResult = DllCall($wtsapiCall,"BOOL","WTSSendMessageA","HANDLE","WTS_CURRENT_SERVER_HANDLE","DWORD",$SessionId[0],"str",DllStructGetData($pTitle, "Title"),"DWORD",DllStructGetSize($pTitle),"str",DllStructGetData($pMessage, "Message"),"DWORD",DllStructGetSize($pMessage),"DWORD","1L","DWORD",$ShutDownWindowTimeout,"DWORD",DllStructGetPtr($pResponse),"BOOL","1")
MsgBox(0, "WinAPILastError", _WinAPI_GetLastError() & "," & _WinAPI_GetLastErrorMessage())
MsgBox(0, "DllCall Response,@error", $SendMessageResult[0] & "," & $SendMessageResult[1] & "," & $SendMessageResult[2] & "," & $SendMessageResult[3] & "," & $SendMessageResult[4] & "," & $SendMessageResult[5] & "," & $SendMessageResult[6] & "," & $SendMessageResult[7]& $SendMessageResult[8] & "," & $SendMessageResult[9] & "," & $SendMessageResult[10])
MsgBox(0, "DllCall pointer response", DllStructGetData($pResponse, "Response"))
DllClose($wtsapiCall)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...