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 获取当前系统语言环境(en,fr,ja等)

Delphi 获取系统托盘程序列表

Delphi xe 跨平台(windows、android安卓、苹果macos、苹果ios)写法

Delphi 类型映射及类型转换

Delphi 简单的定时程序代码

Delphi sql语句查询最新的各个台位的最后一个检测值

Delphi idhttp的用法

Delphi memo1自动循环上下滚屏

Delphi 释放res资源文件

Delphi 获取程序自身大小的函数

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



打赏

取消

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

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

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

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

评论

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