473,385 Members | 1,817 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,385 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 7119
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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.