简体   繁体   中英

How to edit remote registry via c#

How can I edit a remote registry from 32-bit app to 64-bit server.

It very important: remote registry brunch must be 64bit, not 32bit.

I write code like this:

RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, remoteServerName)
 .OpenSubKey(SUBKEY,true);

if (key != null)
{
    key.SetValue(KEY_1, Value_1);
    key.Close();
    key.Dispose();
}

It runs on 64-bit platform and edit 64bit server registry key.

How to edit the same key(64bit branch) via app runs on 32bit platform?

You need to pass an additional argument ( RegistryView.Registry32 ) to OpenRemoteBaseKey like the example below.

RegistryKey key = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine, remoteServerName, RegistryView.Registry32)

These links would be helpful for you. http://msdn.microsoft.com/en-us/library/dd411615(v=vs.110).aspx http://msdn.microsoft.com/en-us/library/microsoft.win32.registryview(v=vs.110).aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM