• Welcome to Valhalla Legends Archive.
 

uptime function

Started by haZe, February 06, 2003, 09:16 AM

Previous topic - Next topic

haZe

how do I create an uptime function? =/

Spht

#1
You ask API Viewer:
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long

haZe

#2
Yeah but what do I do with that?  :-[

Zakath

#3
One easy (if possibly not best) way to do it is to call it when the program is executed, then call it whenever uptime is asked for. Simply subtract and you'll get your effective uptime (as long as you're within GetTickCount's accuracy tolerance).
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

haZe

#4
How do I subtract in vb?  ;D

Yoni

#5
Public Declare Function Subtract Lib "math32" (ByVal A As Long, ByVal B As Long) As Long

Grok

#6
Someone should write a class and place in an ATL COM DLL for that.

haZe

#7
yeah u guys should do that---im retarded and dont know what to do with those declares u gave me
a little more help would be appreciated  :-/

Zakath

There's no subtraction operator in VB?! You must be kidding! You seriously can't say A - B?

As far using the declares...lets see how close I can get this, just by guessing based on what I've picked up...
Dim StartTime As Long
StartTime = GetTickCount()

'when you need to check for uptime:

Dim CurrentTime As Long, Uptime As Long
CurrentTime = GetTickCount()
Uptime = Subtract( CurrentTime, StartTime )

Then you'll need to do the division to determine what the hours, minutes, etc. in Uptime actually are.
Quote from: iago on February 02, 2005, 03:07 PM
Yes, you can't have everybody...contributing to the main source repository.  That would be stupid and create chaos.

Opensource projects...would be dumb.

Noodlez

you can do A - B

here..
Function ParseGTC(count As Long) As String
    Dim Days As long, Hours As Long, minutes As Long, Seconds As Long, Miliseconds As Long
    
    Miliseconds = count Mod 1000
    count = count \ 1000
    Days = count \ (24& * 3600&)
    If Days > 0 Then count = count - (24& * 3600& * Days)
    Hours = count \ 3600&
    If Hours > 0 Then count = count - (3600& * Hours)
    minutes = count \ 60
    Seconds = count Mod 60

ParseGTC = Days & " Days, " & Hours & " Hours, " & minutes & " Minutes, " & Seconds & " Seconds and " & Miliseconds & " Milliseconds."


End Function

Mesiah / haiseM

#10
IIf() > all parsing methods relating to uptime crapola  ;D
]HighBrow Innovations
Coming soon...

AIM Online Status: