There is a sample code of Go Language for get a version of Windows.
package main
import (
"syscall"
)
func abort(funcname string, err int) {
panic(funcname + " failed: " + syscall.Errstr(err))
}
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 != 0 {
abort("LoadLibrary", err)
}
defer syscall.FreeLibrary(h)
proc, err := syscall.GetProcAddress(h, "GetVersion")
if err != 0 {
abort("GetProcAddress", err)
}
r, _, _ := syscall.Syscall(uintptr(proc), 0, 0, 0)
print_version(uint32(r))
}
Results on Windows XP SP3.
Regards.