473,406 Members | 2,705 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,406 software developers and data experts.

Windows Services - How to communicate with them? (update settings, etc.)

Hello,

I'm successfully on my way to finishing up a C# Windows Service now, but now I'm wondering how I can communicate with this service. Services examples seem to be everywhere on the internet now, but what is the best practice for communicating with them?

1) It seems like a control panel is best for setting options, but I cannot find any examples on how to make a control panel item in .NET. Can someone provide a link to an article on how to do this, or give the basic steps.

2) How can the control panel or even a WinForm C# app send messages to the service? Before I was using a service, I was sending messages between apps using RegisterWindowMessage and PostMessage. Everything I've been reading seems to indicate that user defined windows messaging (or any message for that matter) won't work with a service because it doesn't have a window to hear them. Regardless of whether I can create a control panel app or not, I need to figure out how to message between the Control Panel or Helper App and the service (like antivirus programs, backup programs, video card settings, etc. which are service based but have access through an app in the icon tray). Any suggestions, samples, or examples?

Thanks,
-Bill

Nov 22 '05 #1
2 7121
Hi Bill,

Thanks for your post. I reviewed your description carefully, and now I'd
like to share the following information with you:

1. Based on my experience, we are not able to create a control panel applet
in a .NET managed application. As you know, control panel applets are just
standard (unmanaged) DLLs with a particular set of entry points and a .cpl
extension. We have to stick to C++ or someother language that allows you to
export static entry points. I believe the following articles and samples
are helpful for creating a control panel applet:

The platform SDK has some guidance for using C++ :
http://msdn.microsoft.com/library/en.../programmersgu
ide/shell_adv/conpanel.asp

Control Panel Applet Framework
http://www.codeproject.com/win32/cjb...anelapplet.asp

Control Panel Applet using MFC
http://www.codeguru.com/system/Contr...ppletMFC.shtml

2. You can communicate with your service in whatever way suits you¡ªnamed
pipes, thought transference, sticky notes, and so on. For simple requests,
I recommend you use the unmanaed API ControlService() or
ServiceController::ExecuteCommand() in managed application to send a
user-defined control code to the service, and a .NET service can process it
in ServiceBase.OnCustomCommand() method.

ControlService
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/controlservice.asp

ServiceBase.OnCustomCommand Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemserviceprocessservicebaseclassoncustomc ommandtopic.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #2
Hi Bill,

Thanks for your post. I reviewed your description carefully, and now I'd
like to share the following information with you:

1. Based on my experience, we are not able to create a control panel applet
in a .NET managed application. As you know, control panel applets are just
standard (unmanaged) DLLs with a particular set of entry points and a .cpl
extension. We have to stick to C++ or someother language that allows you to
export static entry points. I believe the following articles and samples
are helpful for creating a control panel applet:

The platform SDK has some guidance for using C++ :
http://msdn.microsoft.com/library/en.../programmersgu
ide/shell_adv/conpanel.asp

Control Panel Applet Framework
http://www.codeproject.com/win32/cjb...anelapplet.asp

Control Panel Applet using MFC
http://www.codeguru.com/system/Contr...ppletMFC.shtml

2. You can communicate with your service in whatever way suits you¡ªnamed
pipes, thought transference, sticky notes, and so on. For simple requests,
I recommend you use the unmanaed API ControlService() or
ServiceController::ExecuteCommand() in managed application to send a
user-defined control code to the service, and a .NET service can process it
in ServiceBase.OnCustomCommand() method.

ControlService
http://msdn.microsoft.com/library/de...us/dllproc/bas
e/controlservice.asp

ServiceBase.OnCustomCommand Method
http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemserviceprocessservicebaseclassoncustomc ommandtopic.asp

Hope this helps.

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 22 '05 #3

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

Similar topics

0
by: Stefan Hinz | last post by:
Degan, jumping in to try and solve some problems that look pretty obvious to me ... > #options for default service (mysqld2) > (mysqld2) It should be , not (mysqld2).
1
by: Bill | last post by:
Hello, I'm successfully on my way to finishing up a C# Windows Service now, but now I'm wondering how I can communicate with this service. Services examples seem to be everywhere on the internet...
4
by: Christoph Duesmann | last post by:
Hi ! I wan't to code a service which will be installed on some clients in our network. The service should have the following features : - Scan all properties of the Client (Hardware, Software...
3
by: Chris Paul | last post by:
I'm having trouble with PHP & PostgreSQL/OpenLDAP/Apache on Windows. I've set this up countless times on BSD (piece of cake) but I'm trying to do this on Windows now so that my developer can work...
2
by: deko | last post by:
When to use a privileged user thread rather than a windows service? That's the question raised in a previous post . It was suggested that if the service needs to interact with a WinForms app...
2
by: Jenbo | last post by:
Hi all, I have a task at the minute which involves getting data from csv files into a database and doing some nice auditing on the records in there on a web front end. The csv files are going to be...
6
by: Chris Marsh | last post by:
All I have a database table, changes to the data within which I am interested in acting on. The approach that I'm taking is to have the database update a file every time data is updated. This...
0
AmberJain
by: AmberJain | last post by:
Windows Autorun FAQs: List of autostart locations Linked from the Original article- "Windows Autorun FAQs: Description". Que: Can you list all the autostart locations for windows? Ans: Here is...
6
by: josequinonesii | last post by:
I've searched, I've read, I've tested and re-read numerous post but to no avail yet... Quite simply, the settings I've applied to my httpd.conf, httpd-vhost.conf and my hosts files simply does not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...
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
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
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,...
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...

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.