0

我正在尝试GetComputerNameA从 AutoIt 调用,这是我的代码:

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")  

但是在我运行它之后,它不会打印任何东西,就像脚本崩溃而没有错误一样。
知道为什么它没有调用它吗?

4

1 回答 1

1

它有两个参数,具体来说

BOOL GetComputerNameA(
  LPSTR   lpBuffer,
  LPDWORD nSize
);

第一个是 a LPSTR(指向char数组的指针),第二个是 a LPDWORD(指向 an的指针unsigned int)。

这就是你所说的:

Func _get_computer_name()
    Local $dll_struct = DllStructCreate("char[17]")
    
    $sz = DllStructCreate('int')
    Local $x = DllCall("kernel32.dll","int","GetComputerNameA","ptr",DllStructGetPtr($dll_struct),"int_ptr",DllStructGetPtr($sz))

    Return DllStructGetData($dll_Struct,1)
EndFunc
于 2020-09-21T02:14:07.040 回答