我想在每天一天固定一个时间,
比如说零点,让程序执行一次,
烦劳大家讨论一下该用什么方式实现?

解决方案 »

  1.   

    使用timer控件定时检查系统时间
    使用now获取系统时间
    使用decodetime函数转换系统时间的格式进行比较检查。
      

  2.   

    请看这个例子
    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Timer1: TTimer;
        Edit1: TEdit;
        procedure Timer1Timer(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.Timer1Timer(Sender: TObject);
    begin
    edit1.text:=FormatDateTime('hh:mm:ss',now());
    if edit1.Text='23:16:10' then
    begin
    showmessage('');
    //run ....
    end;end;end.
      

  3.   

    我同意 yuzhantao(家穷,人丑,桦南户口) 的想法!
    我不建议使用timer控件控件,或是其他的控件,小程序要尽量少用的使用系统资源。
    时间测试这方面我还没有好的算法。不过我相信会有高手解决。用系统时间,和起机CPU运行时间。
      

  4.   

    加个timer
    我的程序里有定时的例子:
    procedure Tmain.Timer1Timer(Sender: TObject);
    var
      i: integer;
    begin
      for i:= 0 to combobox1.items.count-1 do
      if (datetimetostr(time) =combobox1.Items[i])  then
        begin
          button1.Click ;
        end;
    end;
      

  5.   

    用TIMER编写一个,
    是很占资源的

    我写的一个只有一个窗口的程序就占了2M的内存空间,建议不用窗体