Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading the registry and Wow6432Node key

I have some code that reads the registry and looks for a value in HKEY_LOCAL_MACHINE\Software\App\ but when running on 64-bit versions of Windows the value is under HKEY_LOCAL_MACHINE\Software\Wow6432Node\App\.

How should I best approach this? Do I need a 64-bit installer or should I rewrite my code to detect both places?

like image 980
Jade M Avatar asked Jan 11 '10 00:01

Jade M


People also ask

What is wow6432node registry key?

The Wow6432 registry entry indicates that you're running a 64-bit version of Windows. The OS uses this key to present a separate view of HKEY_LOCAL_MACHINE\SOFTWARE for 32-bit applications that run on a 64-bit version of Windows.

How do I inspect a registry key?

There are two ways to open Registry Editor in Windows 10: In the search box on the taskbar, type regedit, then select Registry Editor (Desktop app) from the results. Right-click Start , then select Run. Type regedit in the Open: box, and then select OK.

How do I open a 64-bit registry?

To view or edit 64-bit keys, you must use the 64-bit version of Registry Editor (Regedit.exe). You can also view or edit 32-bit keys and values by using the 32-bit version of Registry Editor in the %systemroot%\Syswow64 folder.

What is the registry key?

A registry key can be thought of as being a bit like a file folder, but it exists only in the Windows Registry. Registry keys contain registry values, just like folders contain files. Registry keys can also contain other registry keys, which are sometimes referred to as subkeys.


2 Answers

On an x64 machine, here is an example of how to access the 32-bit view of the registry:

using (var view32 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser,                                             RegistryView.Registry32)) {   using (var clsid32 = view32.OpenSubKey(@"Software\Classes\CLSID\", false))   {     // actually accessing Wow6432Node    } } 

... as compared to...

using (var view64 = RegistryKey.OpenBaseKey(RegistryHive.CurrentUser,                                             RegistryView.Registry64)) {   using (var clsid64 = view64.OpenSubKey(@"Software\Classes\CLSID\", true))   {     ....   } } 
like image 172
Wallace Kelly Avatar answered Sep 21 '22 23:09

Wallace Kelly


If you mark you C# program as x86 (and not Any CPU) then it will see HKEY_LOCAL_MACHINE\Software\Wow6432Node\App as HKEY_LOCAL_MACHINE\Software\App\.

A .NET program for Any CPU will run as a 64-bit process if 64-bit .NET is installed. The 32-bit registry is under the Wow6432Node for 64-bit programs.

like image 29
Arve Avatar answered Sep 22 '22 23:09

Arve