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.