[英]Go syscall call windows
Im currently trying to use user32.dll EnumWindows on Go but seems to not be working 我目前正试图在Go上使用user32.dll EnumWindows,但似乎无法正常工作
var(
user32 = syscall.NewLazyDLL("user32.dll")
procEnumWindows = user32.NewProc("EnumWindows")
)
func EnumWindows() int {
ret, _, _ := procEnumWindows.Call(
syscall.NewCallback(enumWindowsProc),
uintptr(0),
)
return int(ret)
}
func enumWindowsProc(hwnd syscall.Handle, lparam uintptr) bool {
return true
}
Calling EnumWindows will give the following error: 调用EnumWindows会出现以下错误:
panic: compileCallback: output parameter size is wrong
Im not sure how should I use the syscall package... I cant seem to find enough documentation on it 我不知道应该如何使用syscall包...我似乎无法找到足够的文档
On the MSDN doc page it says that the callback should return a BOOL and thats what I am doing? 在MSDN文档页面上,它说回调应该返回一个BOOL,这就是我在做什么?
BOOL
in WinAPI is declared as typedef int BOOL
. WinAPI中的
BOOL
声明为typedef int BOOL
。 So it doesn't match Go's bool
. 所以它与Go的
bool
不匹配。 Specifications doesn't even mention what's the size it has. 规格甚至没有提到它的尺寸。 It's probably 1 byte but it doesn't say it.
它可能是1个字节,但它没有说出来。 You should use
int32
instead. 你应该使用
int32
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.