红枫叶随风 2023-01-05 16:14 采纳率: 100%
浏览 13
已结题

一个服务注册多个实例,但只有一个能正常运行,其余运行均提示 错误 1053

用Delphi开发了一个服务,注册为多实例后,只有一个能正常运行,其余的再运行时会提示错误 1053

服务的 TService 做了处理,按网上的方法,增加了如下代码

  private
    { Private declarations }
    procedure GetServiceName;
    procedure GetServiceDisplayName;
    procedure ServiceLoadInfo(Sender : TObject);

  ......
procedure TMyService.GetServiceDisplayName;
var
  _ServiceDisplayName : String;
begin
  if not FindCmdLineSwitch('display', _ServiceDisplayName) then
    raise Exception.Create('Please specify the service displayname with /display switch');
  DisplayName := _ServiceDisplayName;
  PostLog(llHint, format('Service-DisplayName [%s]', [DisplayName]));
end;

procedure TMyService.GetServiceName;
var
  _ServiceName : String;
begin
  if not FindCmdLineSwitch('name', _ServiceName) then
    raise Exception.Create('Please specify the service name with /name switch');
  Name := _ServiceName;
  PostLog(llHint, format('Service-Name [%s]', [Name]));
end;

procedure TMyService.ServiceLoadInfo(Sender : TObject);
begin
  GetServiceName;
  GetServiceDisplayName;
end;

procedure TMyService.ServiceBeforeInstall(Sender: TService);
begin
  PostLog(llEmergency, 'ServiceBeforeInstall');
  ServiceLoadInfo(Self);
end;

procedure TMyService.ServiceStart(Sender: TService; var Started: Boolean);
begin
  PostLog(llEmergency, 'ServiceStart');
  ServiceLoadInfo(Self);
  Started := True;
end;
注册操作

然后在服务中注册了三个服务

img


然后我分别单独启动 服务 01 \ 02 \ 03 均可以正常运行

问题

当我启动 01 ,正常运行后;
再启动 02 或 03 均会如下提示; 真的搞不懂是什么问题了,还望各位指教

img

备注

三个服务的 Name 、 DisplayName 和路径等参数配置得均不一样;

  • 写回答

1条回答 默认 最新

  • 於黾 2023-01-05 16:29
    关注

    你服务里侦听端口号了,还是访问什么独占的资源了?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 1月6日
  • 已采纳回答 1月5日
  • 创建了问题 1月5日

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line