I have created a windows service in C#. I want this service to be moved to the system tray and have a popup menu with start/stop options and a settings form should also open from the menu.
Can anyone please guide me.
I have created a windows service in C#. I want this service to be moved to the system tray and have a popup menu with start/stop options and a settings form should also open from the menu.
Can anyone please guide me.
I also wanted to do this once, you can do it by adding a NotifyIcon
to the service.
Then adding this to the script
notifyIcon1.MouseClick += notifyIcon1_MouseClick;
void notifyIcon1_MouseClick(object sender, MouseEventArgs e) {
//yourcodehere
}
Then add a ServiceController
class to handle stopping and starting the service
you can also add the following to handle the workstation being locked
Microsoft.Win32.SystemEvents.SessionSwitch +=
new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);
void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e) {
//yourcodehere
}