C # WOW6432 registry node messin things up

Attempting to perform a simple registry entry task to launch a C # application at startup.

Using the basic setup of Win32.RegistryKey , but for some reason it continues to add my keys to the /SOFTWARE/WOW6432/Microsoft/Windows.. etc directory instead of just ol /SOFTWARE/Microsoft/Windows..

I tried to read a little, but there was no simple answer to this question: How do I specifically write the key to /SOFTWARE/Microsoft/Windows Registry Key instead of writing in WOW6432 ? I checked to make sure the Visual C # Express solution file has the platform specified as x86 ... so it compiles correctly ... I just don't want the WOW6432 directory.

Thanks for any advice!

Edit:

Now I use the following and still have not succeeded:

 Microsoft.Win32.RegistryKey localKey32 = Microsoft.Win32.RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, Microsoft.Win32.RegistryView.Registry64); 
+4
source share
4 answers

The goals of the x86 process (i.e. it is a 32-bit process) and when launched on a 64-bit machine under the WOW64 emulator, registry redirection comes into play. For some parts of the registry, the system supports two different representations: one for 32-bit processes and one for 64-bit processes. A list of keys affected by the redirection is given here: Registry keys affected by WOW64 .

Redirection is transparent to the application. 32-bit access to the HKLM\Software process and does not know (really, you do not need to know) that the 64-bit OS actually accesses HKLM\Software\Wow6432Node .

You have several options available to you:

  • Go to the AnyCPU target so that your process runs both 32-bit and 64-bit, depending on the OS. This is inconvenient in the Express version because the target platform cannot be specified from the IDE.
  • Explicitly opening a 64-bit registry view. In .net, this requires a RegistryView listing. However, note that .net 4 is required for this feature and for earlier versions of .net, p / invoke is required to open registry views.
  • Keep targeting x86 and write to HKLM\Software . The 64-bit system will read both registry entries when processing a run at the registry start sections. In other words, your existing approach is already working!

As a last point, I would like to comment that the task of setting up this registry key is best left in the installer. Changing keys under HKLM\Software requires administrator rights, and usually you can only expect administrator rights during installation.

+6
source

Try explicitly opening the registry in a 64 bit view using Registry64 in RegistryView . Similarly, you can open 32 bit using the Registry32 option

According to MSDN

You can specify the registry representation when using OpenBaseKey and OpenRemoteBaseKey (RegistryHive, String, RegistryView) and FromHandle property in the RegistryKey object.

+3
source

Make sure your C # application platform is x64. Because HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node is HKEY_LOCAL_MACHINE\SOFTWARE for x86 applications on x64 OS.

0
source

Not C # to blame, but 64-bit Windows usually.

In Win64, registry values ​​for 32-bit applications (i.e., compiled as x86) are stored in the Wow6432Node node registry, while registry values ​​for 64-bit applications are stored directly in the specified path.

See Registry Redirector , MSDN, and KB Support .

0
source

Source: https://habr.com/ru/post/1392305/


All Articles