473,574 Members | 2,618 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 7954
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.goo glegroups.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.goo glegroups.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1216
by: Carlos Natal | last post by:
Hi all, While creating a windows service using .NET and C# I had to call myForm.ShowDialog() from within a thread I have created inside the OnStart() method. When this window is closed, my thread terminated and the tray icon displayed is removed. The service runs ok while the user is logged on the system. When the user logs off, all...
10
2551
by: Zeljko | last post by:
Hi, I have a form with a tray icon. However, when I minimize the form, it stays visible - not in the task bar (I have showintaskbar property set to false), but in a form of a rectangle sitting above the task bar. Can't figure out why that happens - it looks very ugly... Any ideas ? Zeljko
3
13546
by: Mats-Lennart Hansson | last post by:
Hi, I'm having a hard time getting my service to show a sys tray icon. I've tried to create a separate Windows application where I simply add a notification icon to the form. In the OnStart method of the service I simply try to start the windows application which then should show the icon. I can't get it to work! When I run the separate...
7
6857
by: Danielb | last post by:
I want my application to run most of the time as just an notify icon visible in the system tray, with some dialogs windows that open if the user selects an option from the context menu on the tray icon. I've had a look at the example on code project that creates an application that runs in the system tray: ...
2
1752
by: quilkin | last post by:
Hi I have an control app which starts up with a small info message then sits down as a tray icon while it does its work. When started manually (e.g.from a shortcut) this always works fine. However the app is designed to start automatically (via a windows service) whoever is logged on. Sometimes, when started by the service, neither the info...
5
1347
by: Anup Nair | last post by:
Hi All, I am building a system tray icon App in unmanaged vc++ 7.0, But the tray icon crashes every time the machine goes into the idle mode. I am using TaskbarCreated Registered Message for the tray icon and have set the window handler to the tray structure as a top-level hidden window. But all these methods are of no help. Is there any...
1
2050
by: Janiv Ratson | last post by:
Hello, I have an MFC MDI application and a Windows Forms (2.0) Tray Icon application. I want to run a command on the tray application via my MFC application. There is a "Register" context menu command on the tray icon application. I want to call the Register command from my MFC MDI application. I thought of a windows message. How do I...
3
7918
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory but the tray icon is not there. If I start the program after Windows has booted up the icon shows every time. I am assuming that the reason is...
3
2201
by: Joseph Geretz | last post by:
The conventional approach is easy enough; drop a NotifyIcon onto a Form. When the form is loaded - bingo - the icon appears in the System Tray. I can't use this approach though. I'm writing a service. But I'd like my service to install an icon on the System Tray so that the user can start / stop / and otherwise control the service...
0
7808
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7732
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8101
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6456
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5626
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5302
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3742
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
1347
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1062
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.