471,594 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,594 software developers and data experts.

How to change the Tray icon from a Window Service

Hi,

I want to develop a Window Service in C# that should be capable of
sisplaying the a icon in the window tray.

Based on some logic in service, icon should be changed to some other
color/image and I needed single click, double click event and context
menu also on that tray icon to perform some other operation and show
some window form.

How can I achieve this in a C# windows service?

I have start creating a window service project in C# with the following
components

1. log4net.dll - for logging purpose
2. NotifyIcon class - to show the icon tray and balloon

After compiling and installing the service. when I run this service it
does not show the icon in tray and do not write the messages in the log
file either.

Even if I try to add the MessageBox.Show(), it throws that error like
it is not set to UserInteratice mode....i am still working on this
part.....

Please let me know if somebody have any idea about why icon in tray is
not coming..... service also not throwing any error as i am cathing the
error and writing in text file....
Thanks,
Utkarsh

Nov 17 '05 #1
4 7807
I don't think you'll be able to access the system tray from a windows
service, what if the user logs off?

Instead, I think you can write a seperate windows app and use something
like remoting to communicate with the windows service.

Just my 2 cents.
Nov 17 '05 #2
"utkarsh" <ut***********@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi,

I want to develop a Window Service in C# that should be capable of
sisplaying the a icon in the window tray.

Based on some logic in service, icon should be changed to some other
color/image and I needed single click, double click event and context
menu also on that tray icon to perform some other operation and show
some window form.

How can I achieve this in a C# windows service?

I have start creating a window service project in C# with the following
components

1. log4net.dll - for logging purpose
2. NotifyIcon class - to show the icon tray and balloon

After compiling and installing the service. when I run this service it
does not show the icon in tray and do not write the messages in the log
file either.

Even if I try to add the MessageBox.Show(), it throws that error like
it is not set to UserInteratice mode....i am still working on this
part.....

Please let me know if somebody have any idea about why icon in tray is
not coming..... service also not throwing any error as i am cathing the
error and writing in text file....

This is the wrong approach. It is a security risk and it won't work in all
situations. What will you do when there is more than one person logged on?

You should have two executables, a Service that exposes some functionality
(maybe via .NET Remoting) and a separate executable that the user runs to
display the tray icon and communicate with the service.
Nov 17 '05 #3
You can also check, interact with desktop in the properties for the service
as well.

But as a John wrote, its better to have a service, and create a separate
..exe that comunicate with the service...

//Martin
"utkarsh" <ut***********@gmail.com> skrev i meddelandet
news:11**********************@o13g2000cwo.googlegr oups.com...
Hi,

I want to develop a Window Service in C# that should be capable of
sisplaying the a icon in the window tray.

Based on some logic in service, icon should be changed to some other
color/image and I needed single click, double click event and context
menu also on that tray icon to perform some other operation and show
some window form.

How can I achieve this in a C# windows service?

I have start creating a window service project in C# with the following
components

1. log4net.dll - for logging purpose
2. NotifyIcon class - to show the icon tray and balloon

After compiling and installing the service. when I run this service it
does not show the icon in tray and do not write the messages in the log
file either.

Even if I try to add the MessageBox.Show(), it throws that error like
it is not set to UserInteratice mode....i am still working on this
part.....

Please let me know if somebody have any idea about why icon in tray is
not coming..... service also not throwing any error as i am cathing the
error and writing in text file....
Thanks,
Utkarsh

Nov 17 '05 #4
Thanks for the help..... i am going with John;s idea.....

Utkarsh

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Carlos Natal | last post: by
10 posts views Thread by Zeljko | last post: by
3 posts views Thread by Mats-Lennart Hansson | last post: by
5 posts views Thread by Anup Nair | last post: by
reply views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.