I have written a number of services in the past for Delphi using the framework. I would now like to extend a service with some console like features.
The easiest example I can provide is that I'd like to run the service executable with something like the following from a Command prompt.
> myservice.exe /version
MyService Version 1.0
In the project file, I'd handle the parameter and exit prior to the service initializing and be done.
If ParamStr(1) = '/version' then
begin
writeln ('MyService Version 1.0');
exit;
end;
// Other standard service launch code is after this for proper initialization
// when run as a service, i.e.
if not Application.DelayInitialize or Application Installing then
...
However to get a writeln statement to work, typically I would need the directive {$APPTYPE CONSOLE} in the project file which then breaks the service app Destroy event.
Is there another way to wire up standard output to a console without using the {$APPTYPE CONSOLE} directive for a Delphi Windows Service App?