delphi 取得开机时间 开机时间总长度(可精确到秒,分钟等)


本文整理自网络,侵删。

 

procedure TForm1.Button1Click(Sender: TObject);
//GetTickCount函数可以得到从开以来所经过的毫秒数.再与当前时间相减就可以了!
var
StartTime:TDateTime;
begin
StartTime:=Now-GetTickCount/1000/60/60/24;
showmessage('本次开机时间为:'+DateTimeToStr(StartTime));

{uses DateUtils; SecondsBetween

也可用MinuteBetween,function YearsBetween(const ANow, AThen: TDateTime): Integer;
function MonthsBetween(const ANow, AThen: TDateTime): Integer;
function WeeksBetween(const ANow, AThen: TDateTime): Integer;
function DaysBetween(const ANow, AThen: TDateTime): Integer;
function HoursBetween(const ANow, AThen: TDateTime): Int64;
function MinutesBetween(const ANow, AThen: TDateTime): Int64;
function SecondsBetween(const ANow, AThen: TDateTime): Int64;
function MilliSecondsBetween(const ANow, AThen: TDateTime): Int64; }

showmessage('本次开机总时间长度为:'+inttostr(SecondsBetween(Now,StartTime))+'秒');
end;

相关阅读 >>

Delphi中 tstringlist和thashedstringlist的性能对比

Delphi tfilestream流操作1

Delphi rgbtohsb

Delphi http json 验证token

Delphi 判断当前网络连接方式

Delphi 保存hotkey1.hotkey值

Delphi 数据异或校验

delph i判断ip地址是否正确

Delphi 使电脑睡眠代码

idhttp使用时内存猛增,如何解决

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...