Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notify Icon for Window Service

I have developed win service program which reads a excel file from my local drive and then save this file values to database and now I want to develop a notify icon which will be display to show a message("Excel File Saved In Database") after my service will start and will save excel file to database.

Please give me some hints to solve this.

like image 919
Ammar Raja Avatar asked Oct 12 '12 10:10

Ammar Raja


People also ask

Can a Windows service have a tray icon?

Services run in a different window station than the logged in user, so you can't have a system tray icon for them.

How to use NotifyIcon in c# windows application?

NotifyIcon is a component in Windows Forms that is used to notify users by displaying an icon and an optional popup Balloon tooltip in the notification area of the system taskbar. A context menu can also be added to the NotifyIcon that can be accessed by clicking the right mouse button on the icon.

What is NotifyIcon in VB net?

The Windows Forms NotifyIcon component is typically used to display icons for processes that run in the background and do not show a user interface much of the time. An example would be a virus protection program that can be accessed by clicking an icon in the status notification area of the taskbar.


1 Answers

From Vista onwards, your service will not be allowed to interact with the desktop, so cannot have a UI runnning directly out of the service. You need to build an agent application that starts up at user login that can chat to your service (maybe using WCF).

Here's what MS have to say about doing this:

For more complex interactions, developers should move their UI code into an agent that runs in the user’s session and handles all UI requirements. The agent communicates with the service through RPC or named pipes. If the user initiates the UI interaction by using Control Panel, Internet Explorer, or a similar UI experience, that UI experience should start the agent. The agent then handles all UI interactions. If UI is required but is not initiated by the user, the service must request the agent to start any required UI, instead of attempting to launch that UI by itself. In the rare situation where the service must initiate a user interaction and the agent is not already running, the service should call the CreateProcessAsUser API to start the agent. The agent can then initiate all UI interactions. It is important for developers to carefully review all possible usage scenarios and consider moving all UI code into an agent that runs in the user session.

like image 87
spender Avatar answered Sep 24 '22 06:09

spender