直接上代码
private void SetForceSetCopyCount(string key, object value)
{
RegistryKey office = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Office\11.0\Word\Options", true);
if (office != null && office.GetValue("ForceSetCopyCount") == null)
{
office.SetValue(key, value);
}
string[] keyValues = office.GetValueNames();
Console.WriteLine(keyValues);
}
参考链接:
https://social.msdn.microsoft.com/Forums/vstudio/en-US/0ea4e69b-f6cc-4de3-b776-2a1d8bebcf95/opensubkey-return-null-though-the-key-exist?forum=netfxbcl