[TOC] ## syscall ### syscall.Syscall ``` syscall.Syscall syscall.Syscall6 syscall.Syscall9 syscall.Syscall12 syscall.Syscall15 ``` 分别对应 3个/6个/9个/12个/15个参数或以下的调用 用法 ` syscall.Syscall(trap, nargs, a1, a2, a3)` * nargs 表示调用参数的个数 * 多余的参数, 用0代替 ### 调用dll ``` func abort(funcname string, err error) { panic(funcname + " failed: " + err.Error()) } func print_version(v uint32) { major := byte(v) minor := uint8(v >> 8) build := uint16(v >> 16) print("windows version ", major, ".", minor, " (Build ", build, ")\n") } func main() { h, err := syscall.LoadLibrary("kernel32.dll") if err != nil { abort("LoadLibrary", err) } defer syscall.FreeLibrary(h) proc, err := syscall.GetProcAddress(h, "GetVersion") if err != nil { abort("GetProcAddress", err) } r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0, 0) print_version(uint32(r)) // windows version 6.2 (Build 9200) } ```