zoukankan      html  css  js  c++  java
  • delphi中设置系统时间方法

    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;


  • 相关阅读:
    牛客练习赛24 E:青蛙(最短路)
    菜根谭#10
    菜根谭#9
    菜根谭#8
    菜根谭#7
    菜根谭#6
    菜根谭#5
    菜根谭#4
    菜根谭#3
    菜根谭#2
  • 原文地址:https://www.cnblogs.com/jiangu66/p/3225857.html
Copyright © 2011-2022 走看看