zoukankan      html  css  js  c++  java
  • 程序内部计时器

    业务需求:软件内部一个走动的北京时间,不随本地的操作系统的时间而变化(因为可能本地的时间不准)

    demo:

    unit Unit3;
    
    interface
    
    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
      Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
    
    type
      TForm6 = class(TForm)
        Label1: TLabel;
        Label2: TLabel;
        Timer1: TTimer;
        procedure FormCreate(Sender: TObject);
        procedure Timer1Timer(Sender: TObject);
      private
        FStartTime:TDateTime;
        FStartTick:Int64;
      public
        { Public declarations }
      end;
    
    var
      Form6: TForm6;
    
    implementation
    
    {$R *.dfm}
    
    uses dateutils,qworker;
    
    procedure TForm6.FormCreate(Sender: TObject);
    begin
      //初始时间从淘宝获取,起始时间。
      FStartTime := Now;
      //记录开始的秒数
      FStartTick := GetTimeStamp;
    end;
    
    procedure TForm6.Timer1Timer(Sender: TObject);
    begin
      Label1.Caption := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', Now);
      Label2.Caption := FormatDateTime('yyyy-mm-dd hh:nn:ss.zzz', IncMilliSecond(FStartTime,(GetTimeStamp-FStartTick) div 10));
    end;
    
    end.
  • 相关阅读:
    MySql
    Docker
    达观数据
    Python面试题
    用Python构造ARP请求、扫描、欺骗
    git上传简单的命令行分析
    vue2自定义指令的作用
    自定义指令详解 vue
    文档打印 js
    通过Export2Zip实现表格内容下载成为excel文件
  • 原文地址:https://www.cnblogs.com/del88/p/7146823.html
Copyright © 2011-2022 走看看