本文介绍了如何解决此错误->对注册表项'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ oursetting'的访问被拒绝.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建或读取注册表项,但是访问被拒绝或不允许.
我尝试过的事情:
I want to create or read registry key but access is denied or not allowed.
What I have tried:
string user = Environment.UserDomainName + "\\" + Environment.UserName;
RegistrySecurity rs = new RegistrySecurity();
rs.AddAccessRule(new RegistryAccessRule(user, RegistryRights.ReadKey | RegistryRights.WriteKey | RegistryRights.Delete, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Allow));//To allow permission
RegistryKey rk =Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\OurSetting");
rk.SetValue("setting1", "hello");
rk.Close();
推荐答案
这篇关于如何解决此错误->对注册表项'HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ oursetting'的访问被拒绝.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!