Summary
Yes, your Windows service can have a GUI. However, that GUI has to be a separate project (say a Windows Forms project). It's just that the Windows Forms project and your Windows service project have to use whatever is common in between such as database, APIs (e.g. WCF), library, etc. Typically, you would carry out the necessary functionality inside your Windows service and update state / settings in your Windows Forms application.
Adding Your GUI to Task Tray along with a Shortcut Menu
In the Main method of your Windows Forms application, create an object of the NotifyIcon class. You can also create a ContextMenu object and assign it to the ContextMenu property of the NotifyIcon object to allow the tray icon to have shortcut menu. Here is a sample:
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
using (var icon = new NotifyIcon())
{
icon.Icon = System.Drawing.Icon.ExtractAssociatedIcon(Application.ExecutablePath);
var contextMenu = new ContextMenu();
var mnuProperties = new MenuItem()
{
Text = "Properties"
};
var mnuQuit = new MenuItem()
{
Text = "Quit"
};
mnuProperties.Click += mnuProperties_Click;
mnuQuit.Click += mnuQuit_Click;
contextMenu.MenuItems.Add(mnuProperties);
contextMenu.MenuItems.Add(mnuQuit);
icon.ContextMenu = contextMenu;
icon.Visible = true;
Application.Run();
}
}
private static void mnuQuit_Click(object sender, EventArgs e)
{
Application.Exit();
}
private static void mnuProperties_Click(object sender, EventArgs e)
{
var propertiesForm = new PropertiesForm();
propertiesForm.Show();
}
Needless to mention, you can add as many menu items to the context menu, add forms, etc.
One last point, it doesn't have to be a Windows Forms application. It can very well be a WPF application instead.