你new 一个 serviceapplication,然后在onstart等添加代码就可以了!
下面是部分代码!
procedure TsyipmonitorService.ServiceStart(Sender: TService;
var Started: Boolean);
begin
started:=true;
Fpaused:=false;
LogMessage('started!',EVENTLOG_INFORMATION_TYPE,0,0);
end;
procedure TsyipmonitorService.ServiceStop(Sender: TService;
var Stopped: Boolean);
begin
Stopped:=true;
Fpaused:=true;
LogMessage('stopped!',EVENTLOG_INFORMATION_TYPE,0,0);
end;
procedure TsyipmonitorService.ServicePause(Sender: TService;
var Paused: Boolean);
begin
Paused:=true;
Fpaused:=true;
LogMessage('paused!',EVENTLOG_INFORMATION_TYPE,0,0);
end;
procedure TsyipmonitorService.ServiceExecute(Sender: TService);
var
i:integer;
begin
while not(Terminated)do
begin
if not(Fpaused) then
begin
for i:=0 to 600do
begin
Sleep(100);
if Terminated then
exit;
ServiceThread.ProcessRequests(FALSE);
end;
//执行你的过程
ServiceThread.ProcessRequests(FALSE);
end;
ServiceThread.ProcessRequests(FALSE);
end;
end;
可以把!!!给分