Is it possible to install multiple instances of the same delphi service application?

前端 未结 6 1578
遥遥无期
遥遥无期 2020-12-06 02:24

I have a service application built in Delphi that works great. It does exactly what I want it to do and all is happy. All is fine until I want to run two (or more) instanc

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-06 02:52

    You haven't made it clear what you have tried to change in the TService subclass.

    Have you added a "BeforeInstall" handler?

    Something like:

    procedure TServiceMain.ServiceLoadInfo(Sender : TObject);// new method, not an override
    begin
      Name := ParamStr(2);
      DisplayName := ParamStr(3);
    end;
    
    procedure TServiceMain.ServiceBeforeInstall(Sender: TService);
    begin
      ServiceLoadInfo(Self);
    end;
    procedure TServiceMain.ServiceCreate(Sender: TObject);
    begin
      ServiceLoadInfo(Self);
    end;
    

    If you do this regularly, subclass TService to do thie in the Constructor instead.

    You should do the same in the BeforeUninstall as well - point both events at the same method.

    C:\>servicename /install MyService "My Service Description"
    

提交回复
热议问题