【发布时间】:2011-05-20 14:40:49
【问题描述】:
我在 delphi 中创建了一个 windows 服务。我的代码在 ServiceExecute 中运行
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 什么都不做
不知道我做错了什么,但任何帮助将不胜感激。
谢谢
【问题讨论】:
-
对我来说没有任何问题。