Windows service and settings

Joined
Mar 26, 2009
Messages
15
Programming Experience
Beginner
Hi,

I've have developed a traditional windows form client and server app that communicate asynchronously over TCP/IP (using sockets) to transfer some data.

The client app requires a number of user defined settings before it can communicate with the server and receive data, e.g.

1. Server IP address
2. Port number
3. Data directory where to put data received (e.g. C:\Data)
4. Comma delimited string of IDs (which tells the server what data to send)

Currently I'm using Application settings to store these preferences and things work ok.

I'm thinking of redeveloping the app as a Windows Service with an accompanying Windows Forms GUI app. Essentially the idea was that the Windows Form app would control the service (i.e. start and stop it) and also allow the user to enter in the settings that the service would use. The user would only be allowed change settings when the service is stopped. When started the service would use the settings provided by the GUI and run in the background.

I've created a simple service and GUI that controls the starting and stopping of the service, but I'm not sure how to pass data (i.e. the settings) from the GUI to the service. I know about the ServiceController's ExecuteCommand method but this only allows integers to be passed. After a lot of searching and reading I'm a bit lost and thinking of giving up. I've seen references to pipes, remoting etc. but they all seem very complex and I'd like to enhance my knowledge of services a bit more before having to investigate all these other topics.

So can anybody explain:

How can I send data that include strings to a service - I'm guessing directly is complicated. Is there another way that is not a complete hack/fudge? Is it acceptable to use a file or the registry? If so what locations are best to minimize the problem of different users not being able to access the settings.

How can you ensure that there is only ever one set of settings being used by the service (i.e. no matter who logs on when they open up the GUI app they must all see the same settings)? Is it best to use the Registry or a file and where is best to locate these settings. (I'd prefer not to have to install a database at the client end.)

Thanks
 
Back
Top