Question

I've got 2 applications:

  • Windows Service (with HTTP listener for config website & api)
  • Control Utility (WPF app)

The requirements of the control utility are pretty straightforward:

  • Start / stop service
  • Launch browser pointing to website (e.g. http://local:5555)

Looking for a Windows Service called "MyService", retrieve its status and start it when needed is pretty simple. However, how do I launch the browser with the correct link? The port which the HTTP listener is listening for is configurable inside the app.config of my Windows Service application and there is no possibility to discover the listener. Can a app.config be shared between 2 applications?

I know ConfigurationManager has OpenExeConfiguration(), but this causes other problems:

  • I have to know the path where the Windows Service is installed
  • Reading the configuration may cause a read lock
  • If the config file is encrypted, I have to know the key

Are there any other solutions to achieve this?

Was it helpful?

Solution

You could use the registry for exchanging data.

// Create a Subkey
RegistryKey newKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\\SuperSoft\\App");

// Write Values to the Subkey
newKey.SetValue("Value1", "Content1");
newKey.SetValue("Value2", "Content2");

// read Values from the Subkey
if (SubKeyExist("SOFTWARE\\SuperSoft\\App"))
{
  RegistryKey myKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\SuperSoft\\App");
  string firstApp = (string)myKey.GetValue("Value1");
  string secondApp = (string)myKey.GetValue("Value2");
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top