我直接调用API写服务,但遇上两个问题var
  SvrEntry:array [0..1] of TServiceTableEntry;begin
  SvrEntry[0].lpServiceName:=ServiceName;
  SvrEntry[0].lpServiceProc:=TServiceMainFunction(@ServiceMain);  SvrEntry[1].lpServiceName:=nil;
  SvrEntry[1].lpServiceProc:=nil;
  if not StartServiceCtrlDispatcher(SvrEntry[0]) then
    writeln('Dispatch failed');
end;在上面调用StartServiceCtrlDispatcher的时候根本没执行SERVICEMAIN函数而是直接返回了,错误信息为"the service process could not connect to the service controller",这是什么原因?在卸载的时候是不是应该先DELETESERVICE然后再CLOSESERVICEHANDLE()?
但这时服务对象没有关闭怎么能卸载?如果先关闭再DELETESERVICE会出错,信息为"句柄无效"
请问这又是怎么回事?