windows系统里的事件都是用消息完成了,而且就是通过不停的监测完成的,我想应该只有一个办法,就是用一个timer,但建议判断的时候直接用Tdatetime型数据,不要转换为字符串。
解决方案 »
- delphi正则表达式揭密,TPerlRexEx,DIRegRx,TRegExpr,M$ RegExp
- 对串口的操作封装成DLL
- 有关ADO连接池的问题
- 请问高手 如何在fastreport中作图表chart ?在线等待
- ********对VCL熟悉的高手请进——有点难度的问题:如何在不移动记录指针的情况下得到DBGridEh某个指定单元格的值**********
- MDI窗口问题
- 两个人做的东西如何整合到一块?
- 请教如何将文件中的图片分离?
- 请教高手,在单条记录编辑时,因为显示的字段是不确定的,有什么好的方法控制动态字段的生成与显示位置?
- -------------使用QuickReport如何动态建立ColumnHeaderBand---------------
- 如何同时控制两个TChart?
- 请各位指教
execute 里面写:begin
while not terminated do
begin
sleep(1000);
KillVirus;
end;
end;
begin
Timer1.Enabled:= True;
end;procedure TForm1.Timer1Timer(Sender: TObject);
begin
if TimeToStr(Time) = '09:00:00' then ...
end;应该对效率不会有多大影响的。
Classes, Syncobjs, mmsystem, Windows, SysUtils;type
TPlan = class(TThread)
private
{ Private declarations }
FTime: TDateTime;
FEvent: TEvent;
FMMTimer: MMRESULT;
protected
procedure Execute; override;
public
constructor Create(ATime:TDateTime);
destructor Destroy;override;
end;implementation
{ TPlan }constructor TPlan.Create(ATime: TDateTime);
begin
FTime := ATime;
FEvent := TEvent.Create(Nil,False,False,'');
FreeOnTerminate := True;
FMMTimer := timeSetEvent(1000,0,TFNTimeCallBack(FEvent.Handle),0,
TIME_PERIODIC or TIME_CALLBACK_EVENT_PULSE);
inherited Create(False);
end;destructor TPlan.Destroy;
begin
if FEvent <> nil then
FEvent.Free;
if FMMTimer <> 0 then
timeKillEvent(FMMTimer);
inherited;
end;
procedure TPlan.Execute;
begin
while not Terminated do
begin
FEvent.WaitFor(INFINITE);
if Abs(Time-FTime) < 1/(24*3600) then//当前时间和指定时间相差不到一秒
begin
//do something you want to do;
end;
end;
end;end.
运行看一下,CPU占用率很低的.