J
juliashah
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/CsWindowsServiceDesktop.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.ServiceType' 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.
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/CsWindowsServiceDesktop.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.ServiceType' 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.