On Thu, 7 Apr 2005 02:49:02 -0700, Lalit wrote:
I have tried this.
I am able to show the Systray icon by setting the allow service to interact
with Desktop property checked.
But the Context menu is not shown for that and i also tried the double click
event of notify icon. If i open the Exe of service directly then context menu
is shown.
I would really advise you to follow what i have told you in my other post.
Showing your tray icon directly from your Windows Service with Interact
with desktop is only going to give you problems. You may be able to get it
working fine when you start the service but as soon as you'll log off or if
2 users are logged in simlutaneously, you'll run into troubles.
Keep in mind that a windows service runs under its own user account (often
Local System) and runs independently of whether there is a (or several)
user logged in or not. If you display any UI element from your Windows
Service, you will have to detect users login and logout (and that's not
that trivial) in order to show/hide your UI elements properly. And under
Windows XP with fast user switching on, you'll probably have headaches
trying to display you tray icon on the desktop of the user that is
currently using the computer since there can be any number of interactive
users logged in simultaneously although only one at a time can effectively
use the computer. And be prepared for Windows 2003 where 2 interactive
users can be logged in and use the computer simultaneously (one at the
console, the other one via Remote Desktop).
Using the approach described in my previous post - that is, having a normal
window form application in the startup folder displaying the tray icon and
communicating with your service via for instance .NET Remoting - allows you
to solve all these problems at once and is fairly easy to implement. This
is how all the Windows Services that need a UI (e.g. antivirus sofwtare)
are implemented.