Now this is a simple question. It should be clearly documented in MSDN. I looked but I couldn’t find it. The only thing I got was that I had to open subkey after subkey after subkey to get to the particular key I’m interested in.
Surely there is a more direct method to access a key 3 levels deep. What is it?
I’ve already tried
RegistryKey reg = Registry.LocalMachine;
reg.OpenSubKey(@"Software\Microsoft", true); // reg is still HKLM !
and
reg.OpenSubKey(@"Software\Microsoft\", true); // reg is still HKLM !
I think you are expecting the
OpenSubKey()method to do something toreg– somehow to make it point to the sub key. It doesn’t work that way.OpenSubKey()returns a new object of type RegistryKey which can be used to retrieve the value of, or modify, the sub key. So you need: