Valhalla Legends Archive

Programming => Battle.net Bot Development => Battle.net Bot Development References => Topic started by: haZe on February 06, 2003, 09:16 AM

Title: uptime function
Post by: haZe on February 06, 2003, 09:16 AM
how do I create an uptime function? =/
Title: Re: uptime function
Post by: Spht on February 06, 2003, 09:39 AM
You ask API Viewer:
Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long
Title: Re: uptime function
Post by: haZe on February 06, 2003, 09:50 AM
Yeah but what do I do with that?  :-[
Title: Re: uptime function
Post by: Zakath on February 06, 2003, 09:59 AM
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).
Title: Re: uptime function
Post by: haZe on February 06, 2003, 10:21 AM
How do I subtract in vb?  ;D
Title: Re: uptime function
Post by: Yoni on February 06, 2003, 11:26 AM
Public Declare Function Subtract Lib "math32" (ByVal A As Long, ByVal B As Long) As Long
Title: Re: uptime function
Post by: Grok on February 06, 2003, 11:36 AM
Someone should write a class and place in an ATL COM DLL for that.
Title: Re: uptime function
Post by: haZe on February 06, 2003, 11:40 AM
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  :-/
Title: Re: uptime function
Post by: Zakath on February 06, 2003, 12:22 PM
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.
Title: Re: uptime function
Post by: Noodlez on February 06, 2003, 04:05 PM
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
Title: Re: uptime function
Post by: Mesiah / haiseM on February 06, 2003, 05:13 PM
IIf() > all parsing methods relating to uptime crapola  ;D