您的位置:首页 > 编程语言 > Delphi

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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: