Skip to content

showing wrong uptime value #17

@Abn02

Description

@Abn02

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions