You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.0 KiB
Go
44 lines
1.0 KiB
Go
// +build windows
|
|
|
|
package staros
|
|
|
|
import (
|
|
"time"
|
|
|
|
"b612.me/wincmd"
|
|
|
|
"b612.me/win32api"
|
|
)
|
|
|
|
// StartTime 开机时间
|
|
func StartTime() time.Time {
|
|
data, _ := win32api.GetTickCount()
|
|
date := float64(time.Now().Unix())
|
|
unix := date - float64(data)/1000
|
|
max := (unix - float64(int64(unix))) * 1000000000
|
|
return time.Unix(int64(unix), int64(max))
|
|
}
|
|
|
|
// IsRoot 当前是否是管理员用户
|
|
func IsRoot() bool {
|
|
return wincmd.Isas()
|
|
}
|
|
|
|
// Memory 系统内存信息
|
|
func Memory() MemStatus {
|
|
var mem MemStatus
|
|
ram := new(win32api.MEMORYSTATUSEX)
|
|
win32api.GlobalMemoryStatusEx(ram)
|
|
mem.All = uint64(ram.UllTotalPhys)
|
|
mem.Free = uint64(ram.UllAvailPhys)
|
|
mem.Available = uint64(ram.UllAvailPhys)
|
|
mem.Used = uint64(mem.All - mem.Free)
|
|
mem.SwapAll = uint64(ram.UllTotalPageFile)
|
|
mem.SwapFree = uint64(ram.UllAvailPageFile)
|
|
mem.SwapUsed = mem.SwapAll - mem.SwapFree
|
|
mem.VirtualAll = uint64(mem.VirtualAll)
|
|
mem.VirtualAvail = uint64(mem.VirtualAvail)
|
|
mem.VirtualUsed = mem.VirtualAll - mem.VirtualUsed
|
|
return mem
|
|
}
|