Access 64-bit hklm\software Registry by 32-bit application

Source: Internet
Author: User


While running 32-bit Windows application to a 64-bit Windows OS, there is a registry redirection. Here, if 32-bit application tries to read a key under hklm\software, then due to Registry redirection EF Fective path becomes hklm\software\wow6432node. For example, we is running 64-bit and 32-bit application to read registry keys as hklm\software\xyz and HKLM \SOFTWARE\WOW6432NODE\XYZ.

So by default, with an input of HKLM\Software, 64-bit application would read hklm\software\xyz while Beca Use of registry redirection 32-bit application would read hklm\software\wow6432node\xyz.

In C #, to-read 64-bit hklm\software registry keys, we can use RegistryKey.OpenBaseKey method. This method takes the arguments- RegistryHive and RegistryView . Here, seperate registry views is present for 32-bit and 64-bit.

Here is the sample C # code to read for AppPaths 32-bit and 64-bit applications installed on the system:

try {string AppPath = @ "Software\microsoft\windows\currentversion\app Paths";                    RegistryKey rkbase = null; Rkbase = Registrykey.openbasekey (Microsoft.Win32.RegistryHive.LocalMachine, Registryview.regi                    STRY32); using (RegistryKey RK = rkbase. OpenSubKey (Uninstallkey)) {foreach (String skname in RK. Getsubkeynames ()) {using (RegistryKey SK = rk.                                    OpenSubKey (Skname)) {try { if (SK. GetValue ("Path") = null) {//add this to Requir Ed list}} catch (Except  Ion ex) {                                  MessageBox.Show (ex.                                Message); }}} if (Environment.is64bitope Ratingsystem) {using (RegistryKey RK = Registry.LocalMachine.OpenSubKey (AppPath ) {foreach (String skname in RK). Getsubkeynames ()) {using (RegistryKey SK = rk.                                    OpenSubKey (Skname)) {try {if (SK. GetValue ("Path") = null) {//add this T                                    o Required List}}                           catch (Exception ex)         {MessageBox.Show (ex.                                    Message);                }                                }                            }                        }                    } } catch (Exception ex) {MessageBox.Show (ex.                Message); }

Here, was Environment.Is64BitOperatingSystem used to check if the current system was 64-bit or not. This function was avialable with. NET Framework 4.0.

Access 64-bit hklm\software Registry by 32-bit application

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.