Avoid Registry Wow6432Node Redirection

user1071461 picture user1071461 · Aug 4, 2012 · Viewed 27.9k times · Source

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.

Answer

Hui picture Hui · Apr 3, 2014

You can use RegistryKey.OpenBaseKey to solve this problem:

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