Modify an existing registry key value in c#
12,172
Wow6432Node is not a real path in the registry. It is an alias for 32 bit keys in 64 bit OS.
You must use RegistryView.Registry32 in order to specify you want to work with 32 bits.
RegistryKey reg32key = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);
RegistryKey reg_32bit_AppKey = reg32key.OpenSubKey(@"SOFTWARE\Program\SubProgram");
if (reg_32bit_AppKey != null)
{
// Here you can work with "SOFTWARE\\Wow6432Node\\Program\\SubProgram "
}
Author by
user1914868
Updated on June 04, 2022Comments
-
user1914868 almost 2 years
I want to modify a data in registry path
SOFTWARE\Wow6432Node\Program\SubProgram
using C# code in windows 7. I am able to read the value but I can't write into Registry. Here is the code:RegistryKey SUBKEY; RegistryKey TAWKAY = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, ""); string subkey = "SOFTWARE\\Wow6432Node\\Program\\SubProgram "; if (TAWKAY.OpenSubKey(subkey) != null) // Get values from Registry { TAWKAY = RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, ""); SUBKEY = TAWKAY.OpenSubKey(subkey); // subkey opens SUBKEY = TAWKAY.OpenSubKey(subkey,true); // subkey not open shows error Requested registry access is not allowed SUBKEY.SetValue("Some name", "1234567890"); Console.WriteLine(SUBKEY.GetValue("Some name").ToString()); } else { Console.WriteLine("Cannot open registry"); } Console.Read();
If I set
OpenSubKey(subkey, true)
, it shows an error messageRequested registry access is not allowed
Is there any permission needed to write into registry? Please help me to solve the issue