乐九娱乐城二八杠赌钱

go 獲取電腦信息

/ GO / 0 條評論 / 80瀏覽

獲取磁盤信息

type Storage struct {
	Name       string
	FileSystem string
	Total      uint64
	Free       uint64
}

type storageInfo struct {
	Name       string
	Size       uint64
	FreeSpace  uint64
	FileSystem string
}

func getStorageInfo() {
	var storageinfo []storageInfo
	var loaclStorages []Storage
	err := wmi.Query("Select * from Win32_LogicalDisk", &storageinfo)
	if err != nil {
		return
	}

	for _, storage := range storageinfo {
		info := Storage{
			Name:       storage.Name,
			FileSystem: storage.FileSystem,
			Total:      storage.Size,
			Free:       storage.FreeSpace,
		}
		loaclStorages = append(loaclStorages, info)
	}
	fmt.Printf("localStorages:=", loaclStorages)
}

獲取CPU信息

type cpuInfo struct {
	Name          string
	NumberOfCores uint32
	ThreadCount   uint32
}

func getCPUInfo() {

	var cpuinfo []cpuInfo

	err := wmi.Query("Select * from Win32_Processor", &cpuinfo)
	if err != nil {
		return
	}
	fmt.Printf("Cpu info =", cpuinfo)
}

獲取硬盤序列號

type hardinfo struct {
	InterfaceType string
	SerialNumber string
}

func getHardInfo() {
	var hardinfo []hardinfo

	err := wmi.Query("SELECT * FROM Win32_DiskDrive", &hardinfo)
	if err != nil {
		return
	}

	for _, item := range hardinfo {
		fmt.Println(item)
	}

}