This is not that easy, at least for Windows, because on Windows GUI applications and Services are structured differently and handled differently by the OS.
On Unix this is a different story, because there is no OS level difference between a GUI application and a Daemon, as a GUI application is just an application that calls drawing routines, while a daemon is just an application that doesnt.
What you could do is to write two programs, a Service and a GUI. The service is always executed and runs in the background, while the GUI just connects to the service and interacts with it (e.g. through IPC)