Jump to content

simple uptime function


Recommended Posts

i putting it on this forum so i don't loose it :whistle:

Func _uptime(ByRef $iDays, ByRef $iHours, ByRef $iMins, ByRef $iSecs)
    $iTicks = DllCall("kernel32.dll", "long", "GetTickCount")
    $iTicks = $iTicks[0]
    If Number($iTicks) > 0 Then
        $iTicks = Round($iTicks / 1000)
        $iDays  = Int($iTicks / 86400)
        $iHours = Int($iTicks / 3600)
        $iTicks = Mod($iTicks, 3600)
        $iMins = Int($iTicks / 60)
        $iSecs = Round(Mod($iTicks, 60))
        Return 1
    ElseIf Number($iTicks) = 0 Then
        $iDays = 0
        $iHours = 0
        $iTicks = 0
        $iMins = 0
        $iSecs = 0
        Return 1
        Return 0
EndFunc   ;==>_uptimeoÝ÷ Ú+wöƦ¡Øçoz»"¢z¶'$²Ú-gºØ­­ën®{-멶)µë-yÚ'Æ6Ç«½êðÚMìz»Þ­ìZ^jëh×6Dim $idays
Dim $ihours
Dim $imins
Dim $isecs

MsgBox(0,"Uptime","Days: "&$idays&" Hours: "&$ihours&" mins: "&$imins&" secs: "&$isecs)


Link to comment
Share on other sites

  • 6 months later...

First of all, thanks for sharing, mastrboy. :)

I think I have found a small bug in the hours count: variable $iHours contains the total number of hours, not just the remaining hours when you have removed from the total the number of days the system is online.

Thus, I have changed the $iHours assignment from

$iHours = Int($iTicks / 3600)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...