lxn / win

A Windows API wrapper package for the Go Programming Language
Other
1.19k stars 313 forks source link

Parameter passing problem #30

Open StaticLove opened 6 years ago

StaticLove commented 6 years ago

The parameters of Syscall method in syscall package of golang are defined as such:

func Syscall(trap, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)

but in the project the parameters are indeed passed as such:

func RegCloseKey(hKey HKEY) int32 {
    ret, _, _ := syscall.Syscall(regCloseKey, 1,
        uintptr(hKey),
        0,
        0)

    return int32(ret)
}

I do not quite understand why we can do that?

lxn commented 6 years ago

You probably are looking at the docs at golang.org, which happen to be for Linux.

For Windows, the signature is

func Syscall(trap, nargs, a1, a2, a3 uintptr) (r1, r2 uintptr, err Errno)

If you installed Go via the msi installer, you can start a local godoc with Windows specific syscall docs from your start menu or whatever your Windows version provides.

StaticLove commented 6 years ago

So it is, thank you very much.