I have recently moved to a W7 64bit machine with VS 2010.
My project is set to run on Any CPU. When I change this to be targeted at x86 I noticed some of my registry calls no longer work.
I am trying to read the ProductID field like so:
RegistryKey windowsNTKey = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion");
object productID = windowsNTKey.GetValue("ProductId");
productID is always null when running in x86 mode, when running in “Any CPU” it works correctly. What is going on here?
Some registry keys are redirected by WOW64. More information on this topic is available on MSDN
http://msdn.microsoft.com/en-us/library/aa384232(v=vs.85).aspx
If you really want to always access the x64 node (.Net4) :