473,439 Members | 5,051 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Windows service with icon on taskbar

I've developed a windows service that monitors the database and shows
icon of a different color depending on the data. To be able to show an
icon I have to select the "Allow service to interact with desktop"
checkbox on the service, and when I do it manually, the icon shows just
fine.

But I want the users to double-click the installation file and not have
to go to the Services and select the checkbox. So I used this example
http://www.codeproject.com/csharp/Cs...iceDesktop.asp to check
the checkbox programmatically. I found out that it selected the
checkbox, but the icon still doesn't show. But if I go and manually
deselect and select the checkbox, it starts working. So I figured that
piece of code in the example does select the checkbox, but does not
really change the property of the service.

I also tried this:
ServiceController sc = new ServiceController("MyServiceName");
sc.ServiceType = ServiceType.InteractiveProcess;

but got an error message:
Property or indexer
'System.ServiceProcess.ServiceController.ServiceTy pe' cannot be
assigned to -- it is read only.

So I am wondering if there is any way to allow a service to interact
with desktop programmatically. Would appreciate any help.

Jul 18 '06 #1
4 15670
Julia,

The article that you referenced should be disregarded.

Services should never be set to interact with the desktop. You can not
always assume that there is an interactive user session to work with.

What you should do is have your service expose a remoting endpoint, and
then have an application that runs in the tray that makes calls to the
service through remoting to get/set information and receive feedback.

You can then have this program run on startup so that it is launched
when a user logs in.

Hope this helps.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<ju*******@gmail.comwrote in message
news:11*********************@m73g2000cwd.googlegro ups.com...
I've developed a windows service that monitors the database and shows
icon of a different color depending on the data. To be able to show an
icon I have to select the "Allow service to interact with desktop"
checkbox on the service, and when I do it manually, the icon shows just
fine.

But I want the users to double-click the installation file and not have
to go to the Services and select the checkbox. So I used this example
http://www.codeproject.com/csharp/Cs...iceDesktop.asp to check
the checkbox programmatically. I found out that it selected the
checkbox, but the icon still doesn't show. But if I go and manually
deselect and select the checkbox, it starts working. So I figured that
piece of code in the example does select the checkbox, but does not
really change the property of the service.

I also tried this:
ServiceController sc = new ServiceController("MyServiceName");
sc.ServiceType = ServiceType.InteractiveProcess;

but got an error message:
Property or indexer
'System.ServiceProcess.ServiceController.ServiceTy pe' cannot be
assigned to -- it is read only.

So I am wondering if there is any way to allow a service to interact
with desktop programmatically. Would appreciate any help.

Jul 18 '06 #2
Hello ju*******@gmail.com,

The whole approach is wrong. You should avoid comunication with desktom from
the service.
Service and UI are 2 different things. Service started before user logon
and works in the different security context.

Moreover, in the Windows Vista you have no access to the "Allow service to
interact with desktop" at all.

You need to use some IPC approach to interact with your service from UI.
You can use Pipes, Sockets, Remoting, SOAP, DCOM - everything that suitable
in your case
I've developed a windows service that monitors the database and shows
icon of a different color depending on the data. To be able to show an
icon I have to select the "Allow service to interact with desktop"
checkbox on the service, and when I do it manually, the icon shows
just fine.

But I want the users to double-click the installation file and not
have to go to the Services and select the checkbox. So I used this
example http://www.codeproject.com/csharp/Cs...iceDesktop.asp
to check the checkbox programmatically. I found out that it selected
the checkbox, but the icon still doesn't show. But if I go and
manually deselect and select the checkbox, it starts working. So I
figured that piece of code in the example does select the checkbox,
but does not really change the property of the service.

I also tried this:
ServiceController sc = new ServiceController("MyServiceName");
sc.ServiceType = ServiceType.InteractiveProcess;
but got an error message:
Property or indexer
'System.ServiceProcess.ServiceController.ServiceTy pe' cannot be
assigned to -- it is read only.
So I am wondering if there is any way to allow a service to interact
with desktop programmatically. Would appreciate any help.
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jul 18 '06 #3
Thanks for quick reply, guys.

Ok, I guess my whole approach is wrong. It doesn't have to be a
service. What I need is some kind of program that starts when a user
logs in, it should run in the background and check the database once in
a while. When a certain data appears in the database, an icon on a
taskbar should change. So what is the easiest way to do it?

Jul 18 '06 #4
Hello ju*******@gmail.com,
Thanks for quick reply, guys.

Ok, I guess my whole approach is wrong. It doesn't have to be a
service. What I need is some kind of program that starts when a user
logs in, it should run in the background and check the database once
in a while. When a certain data appears in the database, an icon on a
taskbar should change. So what is the easiest way to do it?
Any app that will start from the Autorun folder

---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
Jul 18 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Rob Y | last post by:
I have a Windows Service created in VB.NET and I'm trying to implement a taskbar icon. I tried using NotifyIcon, but I can only get this to work on a Windows Form. In the Windows Service it...
1
by: Kyzer | last post by:
Hi all, I am writing a DLL which includes a function that may open a dialog. When this dialog is opened, an additional icon and program description is displayed in the Windows taskbar (similar...
2
by: Mullin Yu | last post by:
hi, how can i add an an icon at the right button taskbar like that for MS-SQL server that i can have two options - Start - Stop which will call the OnStart of my Windows service and OnStop...
2
by: Brian | last post by:
Dear my friends, I have been helped by many C# gurus here, thank you very much. My small application can help you fetch some good pictures from Internet. You can get it from...
0
by: Mike | last post by:
Greetings, I have an application that is launched and controlled (hide or show) via DDE messages from another application. The first time the application is launched it shows as it should and...
2
by: flaper87 | last post by:
Hi everybody!!!! I am developing an aplication, and i want it to stay on the system tray, i found out how to put the icon, but i can minimize it there, What do i have to do?, I'm using python(of...
3
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...
2
by: Robert McEuen | last post by:
Access 97/2003 Windows XP (Classic Start Menu) I just converted an mdb from A97 to A2K3 and found something that, after Google search, doesn't appear to have been addressed in cdma... I have...
1
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I was thinking my desktop application a bit easy but when i try to list the open window i got a trouble. I can list my own apps windows but cant list other windows. For Example:: If i run...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.