I'd never use ms for this as it is limited to 49.7 days, after that it wraps around.
Use Date() instead and track the time yourself.
One "trick" is to find out how long smss.exe has been running, as that is the first usermode process started by the OS/kernel.
You could also peek at the system pagefile modified date, which might be the most accurate and easiest method to find this out.
Code: Select all
EnableExplicit
Procedure.s CalculateDays(startdate.i,enddate.i)
Protected result$,seconds.i,minutes.i,hours.i,days.i
seconds=enddate-startdate
If seconds<>0
minutes=seconds/60 : seconds-(minutes*60)
hours=minutes/60 : minutes-(hours*60)
days=hours/24 : hours-(days*24)
If days>0
result$=StrU(days,#PB_Long)+" day"
If Not days=1
result$+"s "
Else
result$+" "
EndIf
EndIf
result$+RSet(StrU(hours,#PB_Long),2,"0")+":"
result$+RSet(StrU(minutes,#PB_Long),2,"0")+":"
result$+RSet(StrU(seconds,#PB_Long),2,"0")
EndIf
ProcedureReturn result$
EndProcedure
Define old_date.l,old_ms.l,new_date.l
old_date=Date()
Delay(1000)
new_date=Date()
Debug "Your PC has been running for "+CalculateDays(old_date,new_date)+" hours."
;We'll fake a old date here.
Debug "Your PC has been running for "+CalculateDays(old_date-10000000,new_date)+" hours."
new_date=Date()
old_date=new_date-(ElapsedMilliseconds()*0.001)
Debug "Your PC has been running for "+CalculateDays(old_date,new_date)+" hours."
old_date=GetFileDate("C:\pagefile.sys",#PB_Date_Modified)
new_date=Date()
Debug "Your PC has been running for "+CalculateDays(old_date,new_date)+" hours."
[/quote]