Sign in to follow this  
Followers 0
jstump1

dllcall passed parameter problem

2 posts in this topic

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)

Share this post


Link to post
Share on other sites



Small tip, something missing:

$SendMessageResult[7]& $SendMessageResult[8]

Share this post


Link to post
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
Sign in to follow this  
Followers 0

  • Similar Content

    • Atoxis
      By Atoxis
      Howdy, this is my first post, massive fan of autoit. 
      I've searched and tried and I would just like people who are better at this than me to let me know if this is even a thing.

      I'd like to perform just a variable. For example, it would be. *see inserted code*
      So what i'm wanting is, create the constant $test, and that variable would be what is followed after the = . Then perform the _FileCreate. Then perform the variable.  Logically or in my head rather.. That variable is declared and is equal to what it is set to above, therefore just placing the variable plainly in the script, it should be equal to what it was declared as.  So what am I doing wrong, and or how can I have autoit just perform the variable.  

       
      #include <File.au3> Const $test = FileWriteLine(@DesktopDir & "\Log.txt", @CRLF ) _FileCreate(@DesktopDir & "\Log.txt") $test  
    • ur
      By ur
      I have a script , during compilation and test execution, it worked perfectly but sometimes I am getting error as "Variable used without being declared."
       
      I understood somewhere in the branching logic this is happening.
       
      But not able to find it exactly.
       
      As I am using multiple include statements.the line number is also not giving accurately.
       

       
      Can anyone suggest what is the approach to resolve this?
    • luckyluke
      By luckyluke
      Hello,
      Im trying to read the output from CMD using Dllcall, here is my code:
      #include <WinAPI.au3> #include <array.au3> Global Const $STD_OUTPUT_HANDLE = -11 Global Const $_CONSOLE_SCREEN_BUFFER_INFO = _ "struct;int dwSizeX;" & _ "short dwSizeY;" & _ "short dwCursorPositionX;" & _ "short dwCursorPositionY;" & _ "short wAttributes;" & _ "short Left;" & _ "short Top;" & _ "short Right;" & _ "short Bottom;" & _ "short dwMaximumWindowSizeX;" & _ "short dwMaximumWindowSizeY;endstruct" $pCmd = Run( "cmd.exe" ) Sleep(1000) $hCmd = WinGetHandle("") ConsoleWrite('handle:' & $hCmd & @CRLF) $aRet = DllCall("kernel32.dll", "int", "AttachConsole", "dword", $pCmd) ;_ArrayDisplay($aRet) If $aRet[0] <> 0 Then $vHandle_data='' $vHandle='' $vHandle_data = DllStructCreate($_CONSOLE_SCREEN_BUFFER_INFO) ; Screen Buffer structure $aRet1 = DllCall("kernel32.dll", "hwnd", "GetStdHandle", "dword", $STD_OUTPUT_HANDLE) if not @error Then $vHandle = $aRet1[0] $aRet = DllCall("kernel32.dll", "int", "GetConsoleScreenBufferInfo", "hwnd", $vHandle, _ "ptr", $vHandle_data) MsgBox(0, '1',DllStructGetData($vHandle_data, 'dwSizeX') & _WinAPI_GetLastErrorMessage()) EndIf It did not work, i got the message 'The handle is invalid'. Please help?
      Thank you in advance!
    • TrashBoat
      By TrashBoat
      Is this possible:
      Executing a function from an include, but taking the function name from a gui input and then executing that function using the include:
      #include <Something.au3> ;input reads "Tree" $functionName = GuiCtrlRead($input1) $functionName(1) And the include is gonna have
      Func Tree($x) If $x = 1 Then $this = "text" MsgBox(0,$this,"whatever") EndFunc is it possible?
    • mihaijulien
      By mihaijulien
      Hello,
      I compiled a script I made that takes a command line parameter (the version of a .msi installer) when launched. The script was compiled with the /console option. The script (.au3) works fine but the executable returns  the following error:  
      Error: array variable has incorrect number of subscripts or subscript dimension range exceeded