Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showing wrong uptime value #17

Open
Abn02 opened this issue Jul 17, 2018 · 0 comments
Open

showing wrong uptime value #17

Abn02 opened this issue Jul 17, 2018 · 0 comments

Comments

@Abn02
Copy link

Abn02 commented Jul 17, 2018

if windows device uptime is more than 50 days, this code not working and returning wrong uptime.

var (
kernel32DLL = syscall.MustLoadDLL("kernel32")

procGetDiskFreeSpace     = kernel32DLL.MustFindProc("GetDiskFreeSpaceW")
procGetSystemTimes       = kernel32DLL.MustFindProc("GetSystemTimes")
procGetTickCount64       = kernel32DLL.MustFindProc("GetTickCount64")
procGlobalMemoryStatusEx = kernel32DLL.MustFindProc("GlobalMemoryStatusEx")

)

func (u *Uptime) Get() error {
r1, _, e1 := syscall.Syscall(procGetTickCount64.Addr(), 0, 0, 0, 0)
if e1 != 0 {
return error(e1)
}
u.Length = (time.Duration(r1) * time.Millisecond).Seconds()
return nil
}

here if device uptime is more than 50 days (4320000000 milliseconds for 50 days), u.Length value is getting wrong...
can any one please help me to fix this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant