我在delphi中創建了一個windows服務。我的代碼在ServiceExecute中運行在delphi中創建Windows服務
procedure TMyService.ServiceExecute(Sender: TService);
while not Terminated do
begin
CallSomeProcedure;
Sleep(1000);
ServiceThread.ProcessRequests(false);
end;
end;
不幸的是,我無法獲得該代碼的運行。即使在我正在調試時,我似乎也不會調用該過程。 Myservice.exe中的代碼如下所示。
begin
if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
Application.CreateForm(TMyService, MyService);
Application.Run;
end.
我可以得到serviceExecute跑,如果我添加
MyService.ServiceExecute(nil);
到MyService.exe但是如果我安裝它,因爲它似乎不是一個服務運行作爲Application.Run什麼都不做
不知道我在做什麼錯,但任何幫助將不勝感激。
謝謝
沒有什麼看起來不對我。 – 2011-05-19 15:08:34