thumbnail
Go获取win8以上系统版本号,位数

2019年了,Go标准库中的syscall.GetVersion还在使用GetVersion….

不多说贴代码

package main

import (
	"fmt"
	"syscall"
	"unsafe"
)

func main() {
	var dwMajorVer int
	var dwMinorVer int
	var dwBuildNumber int
	ntdll := syscall.NewLazyDLL("ntdll.dll")
	RtlGetNtVersionNumbers := ntdll.NewProc("RtlGetNtVersionNumbers")
	RtlGetNtVersionNumbers.Call(uintptr(unsafe.Pointer(&dwMajorVer)), uintptr(unsafe.Pointer(&dwMinorVer)), uintptr(unsafe.Pointer(&dwBuildNumber)))
	dwBuildNumber = dwBuildNumber & 0xffff
	fmt.Println(dwMajorVer,dwMinorVer,dwBuildNumber)
}
//不支持xp以下的系统(不包括xp)
package main

import (
	"fmt"
	"syscall"
	"unsafe"
)
type SystemInfo struct {
	ProcessorArchitecture     uint16
	Reserved                  uint16
	PageSize                  uint32
	MinimumApplicationAddress uintptr
	MaximumApplicationAddress uintptr
	ActiveProcessorMask       uint64
	NumberOfProcessors        uint32
	ProcessorType             uint32
	AllocationGranularity     uint32
	ProcessorLevel            uint16
	ProcessorRevision         uint16
}
func main() {
	kernel32 := syscall.NewLazyDLL("kernel32.dll")
	GetNativeSystemInfo:=kernel32.NewProc("GetNativeSystemInfo")
	a:=new(SystemInfo)
	GetNativeSystemInfo.Call(uintptr(unsafe.Pointer(a)))
	if a.ProcessorArchitecture==9 {
		fmt.Println(64)
	}else {
		fmt.Println(32)
	}
}
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇