Author | Message | Time |
---|---|---|
haZe | how do I create an uptime function? =/ | February 6, 2003, 3:16 PM |
Spht | You ask API Viewer: Public Declare Function GetTickCount Lib "kernel32" Alias "GetTickCount" () As Long | February 6, 2003, 3:39 PM |
haZe | Yeah but what do I do with that? :-[ | February 6, 2003, 3:50 PM |
Zakath | 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). | February 6, 2003, 3:59 PM |
haZe | How do I subtract in vb? ;D | February 6, 2003, 4:21 PM |
Yoni | Public Declare Function Subtract Lib "math32" (ByVal A As Long, ByVal B As Long) As Long | February 6, 2003, 5:26 PM |
Grok | Someone should write a class and place in an ATL COM DLL for that. | February 6, 2003, 5:36 PM |
haZe | 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 :-/ | February 6, 2003, 5:40 PM |
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... [code] 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 ) [/code] Then you'll need to do the division to determine what the hours, minutes, etc. in Uptime actually are. | February 6, 2003, 6:22 PM |
Noodlez | you can do A - B here.. [code] 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[/code] | February 6, 2003, 10:05 PM |
MesiaH | IIf() > all parsing methods relating to uptime crapola ;D | February 6, 2003, 11:13 PM |