在C#中在32位系统上创建注册表项

时间:2017-05-09 17:07:55

标签: c# registry

我正在尝试在Windows注册表中创建不同的密钥(基于32位),但我的对象“registryKey”由于未知原因始终为空。

RegistryKey registryKey = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.CurrentUser, RegistryView.Registry32);
using (registryKey = Registry.CurrentUser.OpenSubKey(@"Software\MyProgram"))
{
     if (registryKey != null)
     {
          registryKey.SetValue("AnyKey", "AnyValue", RegistryValueKind.String);
     }
     else
     {
          Console.Write("object is null ..");
     }
}

0 个答案:

没有答案