计算机已经正常运行了多久的时间?
FunCtion GetSec:double ;
Var
DT,DT0:TdateTime ;
Systime:TSystemTime;
begin
GetLocalTime(SysTime) ;
DT := SystemTimeToDateTime(SysTime) ;
with Systime do
begin
whour := 0;
wminute := 0;
wsecond := 0;
wMilliseconds := 0 ;
end ;
DT0 := SystemTimeToDateTime(Systime) ;
Result:= (DT - DT0)*24*60*60 ;
end ;
****************************
计算机已经正常运行了多久的时间?
function UpTime : string ;
const
ticksperday : Integer = 1000 * 60 * 60 * 24 ;
ticksperhour : Integer = 1000 * 60 * 60 ;
ticksperminute : Integer = 1000 * 60 ;
tickspersecond : Integer = 1000 ;
var
t : Longword ;
d , h , m , s : Integer ;
begin
t := GetTickCount ;
d := t div ticksperday ;
Dec ( t , d * ticksperday );
h := t div ticksperhour ;
Dec ( t , h * ticksperhour );
m := t div ticksperminute ;
Dec ( t , m * ticksperminute );
s := t div tickspersecond ;
Result := 'Uptime: ' + IntToStr ( d ) + ' Days ' + IntToStr ( h ) + ' Hours ' + IntToStr ( m ) +
' Minutes ' + IntToStr ( s ) + ' Seconds' ;
end ;