Delphi 如何研究ServiceStart不启动服务的原因?
我创建了一个service manager应用程序,该应用程序允许安装(使用SC CREATE)、启动(使用与回答:)中的代码非常类似的代码)、停止和卸载服务 该服务是用Delphi编写的windows server exe应用程序 突然(几天前),我无法在特定的机器(Windows Server 2012R2)上启动服务,这发生在我的应用程序上,而不是从Windows服务控制台上 相同的EXE(管理器和服务)在其他机器上工作正常(特别是另一台Windows Server 2012R2和我的Windows 10工作站) 这就是我“测量”的结果: 1) 当我尝试启动服务时,此代码Delphi 如何研究ServiceStart不启动服务的原因?,delphi,windows-services,windows-server-2012-r2,delphi-10-seattle,debugview,Delphi,Windows Services,Windows Server 2012 R2,Delphi 10 Seattle,Debugview,我创建了一个service manager应用程序,该应用程序允许安装(使用SC CREATE)、启动(使用与回答:)中的代码非常类似的代码)、停止和卸载服务 该服务是用Delphi编写的windows server exe应用程序 突然(几天前),我无法在特定的机器(Windows Server 2012R2)上启动服务,这发生在我的应用程序上,而不是从Windows服务控制台上 相同的EXE(管理器和服务)在其他机器上工作正常(特别是另一台Windows Server 2012R2和我的Wi
StartService(schs,0,psTemp)
(WinAPI调用-参考上面的链接)不会返回true
2) 如果我将OutpuDebugString
消息放入dpr中,我将无法在中看到它们,这意味着服务exe未启动
3) 在windows系统事件记录器中,我看到尝试连接到服务时有30秒超时
4) 即使我创建了一个dummyservice.exe,它除了编写一些OutpuDebugString
之外什么都不做,我也无法启动它
这是虚拟服务的实现:
procedure ServiceController(CtrlCode: DWord); stdcall;
begin
Dummy.Controller(CtrlCode);
end;
function TDummy.GetServiceController: TServiceController;
begin
Result := ServiceController;
end;
procedure TDummy.ServiceAfterInstall(Sender: TService);
begin
OutputDebugString('ServiceAfterInstall');
end;
procedure TDummy.ServiceAfterUninstall(Sender: TService);
begin
OutputDebugString('ServiceAfterUninstall');
end;
procedure TDummy.ServiceBeforeInstall(Sender: TService);
begin
OutputDebugString('ServiceBeforeInstall');
end;
procedure TDummy.ServiceBeforeUninstall(Sender: TService);
begin
OutputDebugString('ServiceBeforeUninstall');
end;
procedure TDummy.ServiceExecute(Sender: TService);
var
cnt : Integer;
begin
cnt :=0;
while not Terminated do
begin
inc(CNT);
OutputDebugString(Pwidechar('ServiceExecute Count '+IntTOstr(Cnt)));
Sleep(1000);
ServiceThread.ProcessRequests(False);
end;
end;
procedure TDummy.ServiceStart(Sender: TService; var Started: Boolean);
begin
OutputDebugString('ServiceStart');
end;
procedure TDummy.ServiceStop(Sender: TService; var Stopped: Boolean);
begin
OutputDebugString('ServiceStop');
end;
两周前,在这台特定的机器上,我能够启动服务,但没有做任何特别的事情
我想知道我能做些什么来调试更多,我被卡住了
为什么会有超时,我的服务exe似乎还没有启动(如果是,我想我会在DebugView中看到OutputDebugString
消息)
这只发生在一台机器上,在一台几天前运行正常的机器上
感谢所有能帮忙的人 当启动服务()失败时,
GetLastError()
返回什么?最近在服务失败的机器上是否安装了任何更新或新软件?我在StartService()
之后调用intToStr(GetLastError)+':'+syserrormage(GetLastError)
时遇到了错误1053(问题的标题:),这与我在windows事件日志中看到的错误相同。尚未安装任何应用程序,我已应用windows更新(次要更新)来尝试修复此问题,但问题在此之前就已存在。请检查您的防病毒软件。如果检测到服务已满,许多AV程序将阻止服务执行。有些程序甚至可能会阻止其他试图启动受信任服务的程序。@SilverWarior在此计算机上没有安装AV软件。我还强制执行了所有挂起的WIndows更新,但情况没有改变。有什么想法吗?