There are a bunch of ways to get the system uptime, but the ways I've uncovered, all seem to fail after a period (4 days, 2 weeks, where they just start over again)
I know that there is a finite limit to how high of a resolution can be used with a timer, but what's the best way?
I am writing to an sqlite database, involving mutexes and threads -- so the thread that gets the mutex, might not be "in order" -- so I need to be able to order them in a query so that they can be read in order.
Thanks
-j
(Windows-only, ok)
system uptime?
Re: system uptime?
GetTickCount64 if your system meets the requirements.
Blog: Why Does It Suck? (http://whydoesitsuck.com/)
"You can disagree with me as much as you want, but during this talk, by definition, anybody who disagrees is stupid and ugly."
- Linus Torvalds
Re: system uptime?
Directly from MSDN.GetTickCount_() wrote:The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if the system is run continuously for 49.7 days. To avoid this problem, use the GetTickCount64 function. Otherwise, check for an overflow condition when comparing times.
If you need a higher resolution timer, use a multimedia timer or a high-resolution timer.
Re: system uptime?
yup; knew that; but thanks.
Re: system uptime?
I posted this over there, so may as well post here as a more recent thread.
Code: Select all
Procedure.s UpTime() ; For XP or higher. Pretty much instant now :) ~ em_uk
p=RunProgram("cmd.exe","/c net statistics workstation ","",#PB_Program_Hide|#PB_Program_Open|#PB_Program_Read)
If p
While ProgramRunning(p) : o$+ReadProgramString(p)+#CRLF$ : Wend : CloseProgram(p)
up$=Trim(Mid(o$,FindString(o$,"Statistics since",1)+16)) : up$=Left(up$,FindString(up$,#CRLF$,1)-1)
EndIf
ProcedureReturn up$
EndProcedure
Debug UpTime()
----
R Tape loading error, 0:1
R Tape loading error, 0:1