procedure TForm1.Button1Click(Sender: TObject); begin timer1.Interval:=60*1000; //启动监控,每1分钟检查一次设定时间和当前时间 timer1.Enabled:=true; end;
procedure TForm1.Timer1Timer(Sender: TObject); var l_time: TDateTime; h_time: TDateTime; ss:Int64; begin timer1.enabled:=false; h_time:= strtotime('10:30:00'); l_Time := time; //now是取当前的日期加时间,time只取当前时间 if (h_timel_time) then begin ss:=SecondsBetween(h_time,l_time); //求两个时间相差多少秒 if ss5*60 then begin //如果时间间隔小于5分钟定时启动timer2 timer1.Enabled:=false; showmessage('Inteval seconds:'+inttostr(ss)); timer2.Interval:=ss*1000; timer2.Enabled:=true; end; end else timer1.enabled:=true; end;
procedure TForm1.Timer2Timer(Sender: TObject); begin timer2.enable:=false; showmessage('ok on time run the program'); // start... timer1.Enabled:=true; //再次开始监控 end;