It simply means that the search by key failed: http://msdn.microsoft.com/en-us/library/z9f66s0a.aspx
The reason is simple: the key
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.
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
. If you are checking the path with Regedit, you may see different data, because you are looking at
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(
RegistryKey key = baseKey.OpenSubKey(yourPath, RegistryKeyPermissionCheck.ReadSubTree);
Alternatively, you can work with different data sets for different views/architectures.
Are you getting the picture?
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
First, you need to inquire the "bitness" of the current process. For this, just get the size of the
The remaining option, if this is 4 (32-bits), is where it is being executed, on WoW64 or native platform. This is how:
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.