I'm a little puzzled as to why, when you create a new service application in Delphi XE2, does it include these 3 visual component units?
Vcl.Controls
Vcl.Dialogs
Vcl.Graphics
As far as I know, there's nothing in these units which a Service would require. I can see the Graphics unit possibly being used for some sort of image processing, but that's a matter of a developer's implementation of it. Is there some reason why these units are automatically included in a new service application? If I remove them, it doesn't hurt anything... Or does it?
This is added by the IDE code generator, "just in case"... IDE mainly creates forms, so it will add it to your service module, even if there is no need of UI in your service.
What is funny, is that since Windows Vista/Seven, the services are not able any more to send GDI messages to the desktop, i.e. interact with it. So there is definitively not even a possibility to use dialogs nor UI controls from a Windows service.
In fact, even the SvcMgr.pas
links to Forms.pas + Dialogs.pas
units. So deleting the reference in your own unit will continue to have those units linked.
It appears that Forms.pas + Dialogs.pas
units are needed by SvcMgr.pas
to display some potential error message when the service is installed on the command line.
In fact, your service .exe
is not just running in the background, as a service. It can also be run from the command line, like a regular application, in order to install/uninstall/start/stop the service.
You can take a look at our lighter implementation of Windows services in Delphi - but not the same features - just something to play with the APIs. This version does not link to Forms.pas
nor Dialogs.pas
units.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With