[英]When calling GetComputerNameA, the program crash without errors
I am trying to call GetComputerNameA
from AutoIt, this is my code:我正在尝试从 AutoIt 调用
GetComputerNameA
,这是我的代码:
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 :它有两个参数, 具体来说:
BOOL GetComputerNameA(
LPSTR lpBuffer,
LPDWORD nSize
);
The first is a LPSTR
(pointer to a char
array), the second is a LPDWORD
(pointer to an unsigned int
).第一个是
LPSTR
(指向char
数组的指针),第二个是LPDWORD
(指向unsigned int
的指针)。
Here is how you'd call that:您可以这样称呼它:
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.