Uptime

Hi

How can I read and interpret system uptime under Windows XP ??
szafranAsked:
Who is Participating?
 
heretoreadConnect With a Mentor Commented:
function GetUpTime:String;
var
  Sec, Min, Hour, Day:Cardinal;
begin
  Sec:= GetTickCount div 1000;
  Min:= Sec div 60;
  Hour:= Min div 60;
  Day:= Hour div 24;
  Result:= IntToStr(Day)+':Days, '+IntToStr(Hour mod 24)+':Hours, '+IntToStr(Min mod 60)+':Minutes, '+IntToStr(Sec mod 60)+':Seconds';
end;
0
 
szafranAuthor Commented:
works great
thanks
0
 
szafranAuthor Commented:
@heretoread
is there an easy way to add Years to this function ??
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

 
heretoreadCommented:
There would be no point, as GetTickCount returns a DWORD and only works upto 49.7 days.
0
 
szafranAuthor Commented:
only 49 days ??
i've heard that it can be longer :/

and there is a point because my proggy not only shows current uptime but laso adds it to a summary uptime.
0
 
heretoreadCommented:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/base/gettickcount.asp

There is GetTickCount64(); but thats Vista only.

To get years just take all the days and divide it by 365.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.