Search code examples
c#registrywow64

Avoid Registry Wow6432Node Redirection


I'm trying to insert some simple registry keys using Microsoft.Win32.RegistryKey in c# but the path automatically changes from:

HKEY_LOCAL_MACHINE\SOFTWARE\Test

to

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Test

I tried google but I only get some vague and confusing results. Has anyone dealt with this issue before? Some example code would be much appereciated.


Solution

  • You can use RegistryKey.OpenBaseKey to solve this problem:

    using var baseReg = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64);
    using var reg = baseReg.CreateSubKey("Software\\Test");