I’ve created a .net program that runs as a service. The service runs as the Local System Account. I would like to learn about how to use the Windows Registry to store settings for the program.
I’ve read about how to use the .net classes to read and write values to the registry.
However, I understand that upon installation of the program, my MSI installer will need to create the registry keys where the values will be stored.
How do I determine the appropriate place to create the new registry key?
Update: In this particular case, I the program should always run as the Local System account. However, in the case that it runs as another account I want it to use the same settings. Furthermore, I would like to use a configuration tool to modify the settings which will run as the identity of the logged in user.
Since you are not making your main application’s settings user-centric, then you’ll want to save to HKEY_LOCAL_MACHINE\Software\YourCompanyName\YourApplicationName.
From there, I’d create deeper keys depending on how the application is designed. Form specific settings would go in a subkey with the form’s name. General application settings would go in my application key. In the end, it doesn’t matter to anyone else, so long as it makes sense to you.