C#向注册表添加值

直接上代码

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

发布了336 篇原创文章 · 获赞 124 · 访问量 65万+

猜你喜欢

转载自blog.csdn.net/u013538542/article/details/92771381