在delphi中创建Windows服务
发布时间:2020-12-15 04:27:28 所属栏目:大数据 来源:网络整理
导读:我在delphi中创建了一个 Windows服务.我的代码在ServiceExecute中运行 procedure TMyService.ServiceExecute(Sender: TService); while not Terminated do begin CallSomeProcedure; Sleep(1000); ServiceThread.ProcessRequests(false); end;end; 不幸的是,
我在delphi中创建了一个
Windows服务.我的代码在ServiceExecute中运行
procedure TMyService.ServiceExecute(Sender: TService); while not Terminated do begin CallSomeProcedure; Sleep(1000); ServiceThread.ProcessRequests(false); end; end; 不幸的是,我无法运行此代码.即使在我调试时,我似乎也没有调用该过程. 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什么也不做 不知道我做错了什么,但任何帮助都会非常感激. 谢谢 解决方法
您不能只从IDE运行服务来调试它;在那种情况下,它将退出.该服务必须由服务控制管理器启动.此外,您不应该直接调用ServiceExecute.
这是documentation如何调试服务. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |