我正在尝试在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 ..");
}
}