Home Path to executable on Install Delphi Service
Reply: 1

Path to executable on Install Delphi Service

ewlung
1#
ewlung Published in 2017-09-11 09:00:12Z

Is there any way to put the executable path of Delphi service in double quotes?

I have created a Delphi service and install it by using /install parameter.

If I look via Windows Services, properties, the Path to executable is not enclosed in double quotes.

How to do this in Delphi way?

I am using Delphi 7 and Windows 2012.

Remy Lebeau
2#
Remy Lebeau Reply to 2017-09-11 15:39:53Z

TService does not support customizing the install path during installation time. You have to use the TService.AfterInstall event to edit the Registry directly. You can use ParamStr(0) to get the executable path and then add double quotes to it using AnsiQuotedStr().

procedure TMyService.ServiceAfterInstall(Sender: TService);
var
  Reg: TRegistry;
begin
  Reg := TRegistry.Create;
  try
    Reg.RootKey := HKEY_LOCAL_MACHINE;
    Reg.Access := KEY_SET_VALUE;
    if Reg.OpenKey('\SYSTEM\CurrentControlSet\Services\'+Sender.Name, False) then
    try
      Reg.WriteString('ImagePath', AnsiQuoutedStr(ParamStr(0), '"'));
    finally
      Reg.CloseKey;
    end;
  finally
    Reg.Free;
  end;
end;
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.381682 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO