Interaction with a running Windows service?

How to change the settings of a Windows service while it is running?

Let's say I process files from one directory to another. I would like to be able to declare the output and operations for the following files (while the service is running). It would be ideal if I could edit it remotely through a website (SQL tables or possibly XML / TXT files).

Is this possible without restarting the service? Can I just write the internal service "for all operations of reading the file and output from the settings file"?

I would rather avoid using the Windows Communication Foundation.

+3
source share
5 answers

, Windows, . ServiceController.ExecuteCommand() . ServiceBase.OnCustomCommand() .

. (, ), .

+3

yosh - , settings.xml , . , .

+2

. , - COM, , , - " ".

, ; Win32 API FindFirstChangeNotification(); , , - P/Invoke.

+1

, , , , ..

I personally would recommend playing with * .config and using OpenExeConfiguration . Also, output a few methods that can access / change these parameters, and then use them when you need this value.

Finally, you can have your own XML file with these values ​​and save / retrieve values ​​(and even use the XmlSerializer ), which can be requested when the time comes for processing.

0
source

All Articles