1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00
shirou_gopsutil/host_windows.go

31 lines
555 B
Go
Raw Normal View History

2014-04-18 21:28:00 +09:00
// +build windows
package main
import (
"os"
2014-04-18 22:02:35 +09:00
"syscall"
2014-04-18 21:28:00 +09:00
)
func (h Host) HostInfo() (HostInfo, error) {
ret := HostInfo{}
hostname, err := os.Hostname()
if err != nil {
return ret, err
}
ret.Hostname = hostname
2014-04-18 22:02:35 +09:00
kernel32, err := syscall.LoadLibrary("kernel32.dll")
if err != nil {
return ret, err
}
defer syscall.FreeLibrary(kernel32)
GetTickCount, _ := syscall.GetProcAddress(kernel32, "GetTickCount")
uptimemsec, _, err := syscall.Syscall(uintptr(GetTickCount), 0, 0, 0, 0)
ret.Uptime = int64(uptimemsec) / 1000
2014-04-18 21:28:00 +09:00
return ret, nil
}