delphi中设置系统时间方法
2013-07-30 18:37
423 查看
procedure TMainFrm.Timer1Timer(Sender: TObject);
var
systemtime:Tsystemtime;
dt:TDateTime;
begin
L_DateTime.Caption:=FormatDateTime('YYYY-MM-DD HH:SS',Now); //显示当前时间
MainFrm.Caption:=IntToStr(Timer1.Tag);
timer1.tag:=timer1.tag+1;
if Timer1.tag=60 then begin
Timer1.tag := 0;
if (PC1.ActivePage <> Page_start) then begin
Btn_Input_FirstClick(nil); //返回首页
end;
end;
if copy(L_DateTime.Caption,12,5)='02:00' then begin //晚两点同步时间
try
DM.GetTime.Open;
dt := DM.GetTimeCurrTime.Value;
DateTimeToSystemTime(dt,systemtime); //把Delphi的TDateTime格式转化为API的
SetLocalTime(SystemTime); //设置系统时间
//GetLocalTime(SystemTime); //读取系统时间
//DateTime:=SystemTimeToDateTime(SystemTime); //把API的TSystemTime格式 转化为 Delphi的TDateTime格式
finally
end;
end;
end;
var
systemtime:Tsystemtime;
dt:TDateTime;
begin
L_DateTime.Caption:=FormatDateTime('YYYY-MM-DD HH:SS',Now); //显示当前时间
MainFrm.Caption:=IntToStr(Timer1.Tag);
timer1.tag:=timer1.tag+1;
if Timer1.tag=60 then begin
Timer1.tag := 0;
if (PC1.ActivePage <> Page_start) then begin
Btn_Input_FirstClick(nil); //返回首页
end;
end;
if copy(L_DateTime.Caption,12,5)='02:00' then begin //晚两点同步时间
try
DM.GetTime.Open;
dt := DM.GetTimeCurrTime.Value;
DateTimeToSystemTime(dt,systemtime); //把Delphi的TDateTime格式转化为API的
SetLocalTime(SystemTime); //设置系统时间
//GetLocalTime(SystemTime); //读取系统时间
//DateTime:=SystemTimeToDateTime(SystemTime); //把API的TSystemTime格式 转化为 Delphi的TDateTime格式
finally
end;
end;
end;
相关文章推荐
- delphi中设置系统时间方法
- Android 通过应用设置系统日期和时间的方法
- Delphi获得与设置系统时间格式《转》
- python脚本设置超时机制系统时间的方法
- 设置Linux系统的空闲等待时间TMOUT的方法
- [zt]利用.NET修改设置系统时间的两中方法
- python脚本设置系统时间的两种方法
- delphi动态设置时间格式最有效方法
- win7 和 ubuntu16.04 双系统时间同步设置方法
- Win10系统自由设置时间对电脑进行重启的方法
- 用date命令给CentOS Linux设置修改系统日期和时间的方法
- 鲁大师2015如何设置系统待机时间|鲁大师设置待机时间方法
- Android 通过应用设置系统日期和时间的方法
- Android应用程序设置系统时间的方法
- Delphi获得与设置系统时间格式
- Win8.1系统把时间设置为12小时制的方法
- Delphi获得与设置系统时间格式《转》
- linux服务器系统时间同步设置方法
- Win8系统如何设置时间自动同步方法 电脑系统时间不能同步怎么设置
- 新版 PHP date函数 设置时间与电脑系统时间相差8小时的 解决方法