2013-07-26
展开全部
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_time>l_time) then begin
ss:=SecondsBetween(h_time,l_time); //求两个时间相差多少秒
if ss<5*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');
timer1.Enabled:=true; //再次开始监控
end;自己加入要执行程序的代码...或者用Timer2替掉也行实现
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_time>l_time) then begin
ss:=SecondsBetween(h_time,l_time); //求两个时间相差多少秒
if ss<5*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');
timer1.Enabled:=true; //再次开始监控
end;自己加入要执行程序的代码...或者用Timer2替掉也行实现
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询