procedure TForm1.Timer1Timer(Sender: TObject); var MyTime:string; begin Timer1.Interval:=10000;//每十秒检测一次系统时间 MyTime:=FormatDateTime('hh:nn',now); if MyTime='23:00' then ShowMessage('到时间睡觉了!'); end;
procedure TForm1.Timer1Timer(Sender: TObject); var MyTime:string; begin Timer1.Interval:=1000;//每秒检测一次系统时间 MyTime:=FormatDateTime('hh:mm:ss',now); if MyTime='23:00:00' then ShowMessage('到时间干活了!'); end;
var
MyTime:string;
begin
Timer1.Interval:=10000;//每十秒检测一次系统时间
MyTime:=FormatDateTime('hh:nn',now);
if MyTime='23:00' then
ShowMessage('到时间睡觉了!');
end;
var
MyTime:string;
begin
Timer1.Interval:=1000;//每秒检测一次系统时间
MyTime:=FormatDateTime('hh:mm:ss',now);
if MyTime='23:00:00' then
ShowMessage('到时间干活了!');
end;
用两个Timer,Timer1,Timer2,
其中Timer2.Interval:=1000;初始Timer2.Enabled := False;
先用Timer1获取一次时间,然后判断当前时间与指定时间的差,
然后指定Timer1的Interval属性为这个'差'减1000,待到再次触发Timer1时,使Timer2 Enable
在Timer2中触发事件,然后Timer2.Enabled := False