I’m working on a .net application that will be used for auditing the configuration of each computer that it runs on.
I would like to be able to read the value of any registry key specified by a string, for example: HKEY_LOCAL_MACHINE\SOFTWARE\MyOrganization\MyProgram
In order to get a handle on this key in .net, I write the following:
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\MyOrganization\\MyProgram);
As you can see, I have refer to HKEY_LOCAL_MACHINE using Registry.LocalMachine.
Is there a way to refer to registry keys by name without having to refer to these fields in the Registry object?
I believe you can use the
Registry.GetValue(...)method. The first parameter is the full key name, including the root.