这条线有效:
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(
baseKeyName + subKey, RegistryKeyPermissionCheck.ReadWriteSubTree);
虽然这些行产生SecurityException - 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。
有人有任何想法或解决方法吗?