Delphi Service Application: How to install the service by passing parameters that will be read via code when running?

Asked

Viewed 224 times

0

I created a simple service application by Delphi.

I need that at the time of installing the service in windows, I pass some parameters that will be read and used at the time the service starts:

Example: myServiceApp /install -arg1 -arg2

I tried that way but it doesn’t work. I also tried to "force" the boot parameters by the property of the installed service, but I could not get the value of this parameter via Paramstr().

How to pass these initial parameters and how to read the value from Delphi?

1 answer

1

I was able to solve it this way:

Parâmetros na inicialização do serviço

  1. I added the parameters to the service property.
  2. In the Onstart() event in Delphi, I can get the values of these parameters through Param[index]:

Evento OnStart do Serviço em Delphi

  • I’m glad it did. But you couldn’t create an INI file with the parameters?

  • Yes, it was another option. Problem now is that when installing on the client server (Windows Server 2012) the service does not start (start).

  • some error right at startup... is to treat everything with Try catch and put on Viewer Event.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.