I write a Windows network application that can be launched over the LAN. On the server where the application resides runs also a Windows service that controls the license rules. When the application is started the application tries to establish a TCP connection to the service and sends some data. By this data the service can check if the application is allowed to run.
For the application<>service conversation I need the IP address of the server and the port the service is listening. I can programmaticaly find out the IP address of the server from where the application is started from but it's not possible to find out the port. I could set a fix port number in the application and in the service. But this is error prone since the port could also be used by another application of another company. So it's preferable to let the user change the port dynamically. I could do that easily in the service manager application where the administrator can change license settings.
Now my problem is, how can the service inform the instances of the application on which port they should connect to the service. As the application runs on clients, there is no way to read Registry settings of the server (right?). On XP servers the service manager could just write the port number into a file that the application could read easily as this file would be in its exe directory. But on VISTA servers I mustn't save or changes files into the program folder.
Can anybody tell me how such problems are normally solved?
Is there a way to pass some dynamic parameters when an application is started from the server?
What data can an application read from the server where it is started from?
Any comments are very appreciated.