这行有效:

RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(
    baseKeyName + subKey, RegistryKeyPermissionCheck.ReadWriteSubTree);

这些行产生SecurityException - Requested registry access is not allowed on the OpenSubKeySecurityException - Requested registry access is not allowed on the OpenSubKey

RegistryKey baseKey = RegistryKey.OpenBaseKey(
   RegistryHive.LocalMachine, RegistryView.Registry32);
RegistryKey registryKey = baseKey.OpenSubKey(
   baseKeyName + subKey, RegistryKeyPermissionCheck.ReadWriteSubTree);

在同一台Win7机器上。

我这样做是因为在“真实”代码中有一个条件,它将在64位计算机上使用Registry64 RegistryView。

任何人有任何想法或解决方法吗?

===============>>#1 票数:0

除非应用程序以管理员身份运行,否则不允许写入LocalMachine注册表区域。

  ask by user2284443 translate from so

未解决问题?本站智能推荐: