I created a service in Delphi 10.2.3 and it runs well.
To debug it, I added this in the dpr file:
{$ifdef DEBUG}
try
// In debug mode the server acts as a console application.
WriteLn('MyServiceApp DEBUG mode. Press enter to exit.');
// Create the TService descendant manually.
EseguiProcessiClient := TEseguiProcessiClient.Create(nil);
// Simulate service start.
EseguiProcessiClient.ServiceStart(EseguiProcessiClient, MyDummyBoolean);
// Keep the console box running (ServerContainer1 code runs in the background)
ReadLn;
// On exit, destroy the service object.
FreeAndNil(EseguiProcessiClient);
except
on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
WriteLn('Press enter to exit.');
ReadLn;
end;
end;
{$else}
if not Application.DelayInitialize or Application.Installing then
Application.Initialize;
Application.CreateForm(TEseguiProcessiClient, EseguiProcessiClient);
Application.Run;
{$endif}
This way, I can debug it without problems.
But now, I wanted to change the service name at runtime, so I followed this answer:
https://stackoverflow.com/a/612938/1032291
But now, when I run the service in Release mode, if I keep the original name (EseguiProcessiClient) I have no problems, but if I change the name to something else, the service does not start. It looks like it enters in the ServiceCreate event, but not in the ServiceStart event.
What can I try next?