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.
27 lines
709 B
Go
27 lines
709 B
Go
4 years ago
|
// +build windows
|
||
|
|
||
|
package staros
|
||
|
|
||
|
import "b612.me/win32api"
|
||
|
|
||
|
// Memory 系统内存信息
|
||
|
func Memory() (MemStatus, error) {
|
||
|
var mem MemStatus
|
||
|
ram := new(win32api.MEMORYSTATUSEX)
|
||
|
_, err := win32api.GlobalMemoryStatusEx(ram)
|
||
|
if err != nil {
|
||
|
return mem, err
|
||
|
}
|
||
|
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, nil
|
||
|
}
|