implements Host.Uptime on windows
This commit is contained in:
parent
ce81975573
commit
5fc807ed23
|
@ -4,6 +4,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (h Host) HostInfo() (HostInfo, error) {
|
func (h Host) HostInfo() (HostInfo, error) {
|
||||||
|
@ -15,5 +16,15 @@ func (h Host) HostInfo() (HostInfo, error) {
|
||||||
|
|
||||||
ret.Hostname = hostname
|
ret.Hostname = hostname
|
||||||
|
|
||||||
|
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
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue