本文整理汇总了Golang中syscall.GetVersion函数的典型用法代码示例。如果您正苦于以下问题:Golang GetVersion函数的具体用法?Golang GetVersion怎么用?Golang GetVersion使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetVersion函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetVersion
/*
https://msdn.microsoft.com/en-us/library/ms724832(VS.85).aspx
Windows 10 10.0*
Windows Server 2016 10.0*
Windows 8.1 6.3*
Windows Server 2012 R2 6.3*
Windows 8 6.2
Windows Server 2012 6.2
Windows 7 6.1
Windows Server 2008 R2 6.1
Windows Server 2008 6.0
Windows Vista 6.0
Windows Server 2003 R2 5.2
Windows Server 2003 5.2
Windows XP 64-Bit Edition 5.2
Windows XP 5.1
Windows 2000 5.0
*/
func GetVersion() (int, int, int) {
v, err := syscall.GetVersion()
if err != nil {
panic(err)
}
return int(uint8(v)), int(uint8(v >> 8)), int(uint16(v >> 16))
}
示例2: StartMonitor
func StartMonitor() {
var apiVersion uint32
// xp (5.1) uses version 1 of the api, Vista (6.0) uses version 2
switch v, _ := syscall.GetVersion(); {
case v&0xff == 5:
if (v>>8)&0xFF > 0 {
apiVersion = 1
} else {
// Windows 2000
fmt.Fprintln(os.Stderr, "Requires Windows XP or later")
os.Exit(10)
}
case v&0xff > 5:
apiVersion = 2
default:
// Earlier than Windows 2000. Its probably crashed before reaching here!
fmt.Fprintln(os.Stderr, "Requires Windows XP or later")
os.Exit(10)
}
e := WlanOpenHandle(apiVersion, 0, &apiVersion, &handle)
if e != ERROR_SUCCESS {
fmt.Fprintln(os.Stderr, "WlanOpenHandle: ", e.Error())
os.Exit(int(e))
}
}
示例3: isWindowsXP
func isWindowsXP(t *testing.T) bool {
v, err := syscall.GetVersion()
if err != nil {
t.Fatalf("GetVersion failed: %v", err)
}
major := byte(v)
return major < 6
}
示例4: osVersion
// osVersion returns the OS version.
func osVersion() string {
v, err := syscall.GetVersion()
if err != nil {
return "0.0"
}
major := uint8(v)
minor := uint8(v >> 8)
return fmt.Sprintf("%d.%d", major, minor)
}
示例5: probeWindowsIPStack
func probeWindowsIPStack() (supportsVistaIP bool) {
v, err := syscall.GetVersion()
if err != nil {
return true // Windows 10 and above will deprecate this API
}
if byte(v) < 6 { // major version of Windows Vista is 6
return false
}
return true
}
示例6: init
func init() {
v, err := syscall.GetVersion()
if err != nil {
return
}
if major := byte(v); major < 6 {
// Windows XP SP2 and Windows 2003 do not support SHA2.
// http://blogs.technet.com/b/pki/archive/2010/09/30/sha2-and-windows.aspx
supportSHA2 = false
}
}
示例7: GetOSVersion
// GetOSVersion gets the operating system version on Windows. Note that
// docker.exe must be manifested to get the correct version information.
func GetOSVersion() (OSVersion, error) {
var err error
osv := OSVersion{}
osv.Version, err = syscall.GetVersion()
if err != nil {
return osv, fmt.Errorf("Failed to call GetVersion()")
}
osv.MajorVersion = uint8(osv.Version & 0xFF)
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
osv.Build = uint16(osv.Version >> 16)
return osv, nil
}
示例8: GetOSVersion
// GetOSVersion gets the operating system version on Windows. Note that
// docker.exe must be manifested to get the correct version information.
func GetOSVersion() OSVersion {
var err error
osv := OSVersion{}
osv.Version, err = syscall.GetVersion()
if err != nil {
// GetVersion never fails.
panic(err)
}
osv.MajorVersion = uint8(osv.Version & 0xFF)
osv.MinorVersion = uint8(osv.Version >> 8 & 0xFF)
osv.Build = uint16(osv.Version >> 16)
return osv
}
示例9: GetWindowsVersion
// GetWindowsVersion returns the Windows version information. Applications not
// manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version
// value (6.2).
//
// For a table of version numbers see:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx
func GetWindowsVersion() (major, minor, build int) {
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
ver, err := syscall.GetVersion()
if err != nil {
// GetVersion should never return an error.
panic(fmt.Errorf("GetVersion failed: %v", err))
}
major = int(ver & 0xFF)
minor = int(ver >> 8 & 0xFF)
build = int(ver >> 16)
return major, minor, build
}
示例10: GetWindowsVersion
// GetWindowsVersion returns the Windows version information. Applications not
// manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version
// value (6.2).
//
// For a table of version numbers see:
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724833(v=vs.85).aspx
func GetWindowsVersion() Version {
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx
ver, err := syscall.GetVersion()
if err != nil {
// GetVersion should never return an error.
panic(fmt.Errorf("GetVersion failed: %v", err))
}
return Version{
Major: int(ver & 0xFF),
Minor: int(ver >> 8 & 0xFF),
Build: int(ver >> 16),
}
}
示例11: GetKernelVersion
func GetKernelVersion() (*KernelVersionInfo, error) {
var (
h syscall.Handle
dwVersion uint32
err error
)
KVI := &KernelVersionInfo{"Unknown", 0, 0, 0}
if err = syscall.RegOpenKeyEx(syscall.HKEY_LOCAL_MACHINE,
syscall.StringToUTF16Ptr(`SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\`),
0,
syscall.KEY_READ,
&h); err != nil {
return KVI, err
}
defer syscall.RegCloseKey(h)
var buf [1 << 10]uint16
var typ uint32
n := uint32(len(buf) * 2) // api expects array of bytes, not uint16
if err = syscall.RegQueryValueEx(h,
syscall.StringToUTF16Ptr("BuildLabEx"),
nil,
&typ,
(*byte)(unsafe.Pointer(&buf[0])),
&n); err != nil {
return KVI, err
}
KVI.kvi = syscall.UTF16ToString(buf[:])
// Important - docker.exe MUST be manifested for this API to return
// the correct information.
if dwVersion, err = syscall.GetVersion(); err != nil {
return KVI, err
}
KVI.major = int(dwVersion & 0xFF)
KVI.minor = int((dwVersion & 0XFF00) >> 8)
KVI.build = int((dwVersion & 0xFFFF0000) >> 16)
return KVI, nil
}
示例12: checkSystem
// checkSystem validates platform-specific requirements
func checkSystem() error {
var dwVersion uint32
// TODO Windows. May need at some point to ensure have elevation and
// possibly LocalSystem.
// Validate the OS version. Note that docker.exe must be manifested for this
// call to return the correct version.
dwVersion, err := syscall.GetVersion()
if err != nil {
return fmt.Errorf("Failed to call GetVersion()")
}
if int(dwVersion&0xFF) < 10 {
return fmt.Errorf("This version of Windows does not support the docker daemon")
}
return nil
}
示例13: Version
// Version returns bot version, os and Go runtime info on Windows.
func Version() (os string, rt string) {
os = runtime.GOOS
var flavor string
if ver, err := syscall.GetVersion(); err == nil {
var major, minor, build = byte(ver), uint8(ver >> 8), uint16(ver >> 16)
switch {
case major == 4:
switch minor {
case 0:
flavor = "NT"
case 10:
flavor = "98"
case 90:
flavor = "Me"
}
case major == 5:
switch {
case minor == 2:
flavor = "2003"
case minor == 1 && build == 2600:
flavor = "XP"
case minor == 0:
flavor = "2000"
}
case major == 6:
switch minor {
case 3:
flavor = "8.1"
case 2:
flavor = "8"
case 1:
flavor = "7"
case 0:
flavor = "Vista"
}
}
os = fmt.Sprintf("%s %s: [Version %d.%d.%d]",
strings.Title(runtime.GOOS), flavor,
major, minor, build)
}
rt = fmt.Sprintf("%s %s/%s", runtime.Version(), runtime.GOOS, runtime.GOARCH)
return os, BOTVERSION + " (" + rt + ")"
}
示例14: checkSystem
// checkSystem validates the system is supported and we have sufficient privileges
func checkSystem() error {
var dwVersion uint32
// TODO Windows. Once daemon is running on Windows, move this code back to
// NewDaemon() in daemon.go, and extend the check to support Windows.
if runtime.GOOS != "linux" && runtime.GOOS != "windows" {
return ErrSystemNotSupported
}
// TODO Windows. May need at some point to ensure have elevation and
// possibly LocalSystem.
// Validate the OS version. Note that docker.exe must be manifested for this
// call to return the correct version.
dwVersion, err := syscall.GetVersion()
if err != nil {
return fmt.Errorf("Failed to call GetVersion()")
}
if int(dwVersion&0xFF) < 10 {
return fmt.Errorf("This version of Windows does not support the docker daemon")
}
return nil
}