I am trying to call GetComputerNameA
from AutoIt, this is my code:
Local $mystruct = DllStructCreate(toStr("struct;dword;char[1024];endstruct"))
DllStructSetData($mystruct, 1, 1024)
Local $result = DllCall("kernel32.dll", "int", "GetComputerNameA", "ptr", DllStructGetPtr($mystruct, 2), "ptr", DllStructGetPtr($mystruct, 1))
MsgBox(0, "AutoIt", "Success")
But after I run it, it doesn't print anything, like the script crashed without errors.
Any idea why it failed to call it?
It has two parameters, specifically:
The first is a
LPSTR
(pointer to achar
array), the second is aLPDWORD
(pointer to anunsigned int
).Here is how you'd call that: