Does anyone know how to debug a Delphi-written service (Service Application) on Windows?
I am making an API that get data from rclone and show it on an interface, and I want to make that into a Windows service. If there is anything that you think that can help me, I'd appreciate it.
You can debug it like any other app. The only trick is you have to start the service first in the SCM, and then you can attach Delphi's debugger to the service process, and then debugging works normally.
In my own services, I usually add code in the
TService.OnStartevent to look for a/debugger-style parameter in theTService.Paramproperty, and if present then useIsDebuggerPresent()in a wait loop until the debugger attaches before continuing with my normal service logic. That value can be passed in the SCM startup parameters. For example: