Jump to content
Sign in to follow this  

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)


Share this post

Link to post
Share on other sites

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)

Share this post

Link to post
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
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.