It simply means that the search by key failed:
http://msdn.microsoft.com/en-us/library/z9f66s0a.aspx[
^].
The reason is simple: the key
path
is not found. Use Regedit to check it up. I also can tell you that the problem is not related to the lack of required privilege: in such case, the call would throw an exception.
[EDIT #1]
Please see my comment below.
Here is your problem: you are working with x86
instruction-set architecture via WoW64 on one of the 64-but. Your registry has separate different views per architecture, so, by default, you are using the view
Microsoft.Win32.RegistryView.Registry32
. If you are checking the path with Regedit, you may see different data, because you are looking at
RegistryView.Registry64
.
So, if you need to access some registry data in one view, you should decide which one. Then, in general case, you should specify the view explicitly:
RegistryKey baseKey = RegistryKey.OpenBaseKey(
RegistryHive.LocalMachine,
RegistryView.Registry64);
RegistryKey key = baseKey.OpenSubKey(yourPath, RegistryKeyPermissionCheck.ReadSubTree);
Alternatively, you can work with different data sets for different views/architectures.
Are you getting the picture?
[EDIT #2]
Besides, you may need to have different code for different target instruction-set architectures. For example, on the 32-bit system, you may need to use
Default
key.
First, you need to inquire the "bitness" of the current process. For this, just get the size of the
IntPtr
:
http://msdn.microsoft.com/en-us/library/system.intptr.size.aspx[
^].
The remaining option, if this is 4 (32-bits), is where it is being executed, on WoW64 or native platform. This is how:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms684139%28v=vs.85%29.aspx[
^].
Apply some logic. Note, that you don't have to determine exact 64-bit architecture for your purpose (x86-64 or Itanium), which would be more difficult.
See also:
http://en.wikipedia.org/wiki/WOW64[
^],
http://en.wikipedia.org/wiki/X86[
^],
http://en.wikipedia.org/wiki/X86-64[
^],
http://en.wikipedia.org/wiki/Itanium[
^].
—SA