Get the time elapsed since last Window boot  

Send By: Utilmind
Web : N.A.
Email: utilmind@bigfoot.com
Date: 11/09/99

Tip accessed 478 times

 



 procedure TForm1.Button4Click(Sender: TObject);

   function Uptime: string;
   var
     count,
     days,
     min,
     hours,
     seconds  : longint;
   begin
    {Obtenemos milisegundos transcurridos}
    {Gets windows uptime in msec}
    Count := GetTickCount();
    {Lo convertimos a dd-hh-mm-ss}
    {Coverts msec into dd-hh-mm-ss}
    Count := Count div 1000;
    Days := Count div (24 * 3600);
    if Days > 0 then
     Count := Count - (24 * 3600 * Days);
     Hours := Count div 3600;
    If Hours > 0 Then
     Count := Count - (3600 * Hours);
    Min := Count div 60;
    Seconds := Count Mod 60;
    {Damos el resultado, en una string}
    {Gives the result and converts it into string}
    Result := IntToStr(Days)+' Days '+IntToStr(Hours)+
              ' hours '+IntToStr(Min)+' minutes '+
              IntToStr(seconds) +' seconds ';
   end;
 begin
   Label1.Caption:=Uptime;
 end;



Attention, the internal timer wraps around to zero if Windows is run continuously for approximately 49.7 days.