I've been experimenting with Go and Win32, and I found these two variants for calling OS functions (code is abbreviated):
modUser32 = syscall.NewLazyDLL("user32.dll")
procMessageBox = modUser32.NewProc("MessageBoxW")
// 1st variant
syscall.Syscall6(procMessageBox.Addr(), 4,
uintptr(hwnd), toUtf16(msg), toUtf16(caption), uintptr(flags),
0, 0)
// 2nd variant
procMessageBox.Call(uintptr(hwnd), uintptr(hwnd),
toUtf16(msg), toUtf16(caption), uintptr(flags))
2nd variant is obviously simpler, but are there any disadvantages to it?
They basically don't make much difference, Syscall
may just be a layer of encapsulation for the Call
. Both variants have a limit on the number of parameters.
syscall.Syscall
syscall.Syscall6
syscall.Syscall9
syscall.Syscall12
syscall.Syscall15
Corresponding to parameters <= 3/6/9/12/15.
Call()
method has up to 15 parameters.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.