[英]How to read and write LocalMachine registry keys
我正在为我的应用程序开发一个visio插件,在这种情况下,我有一个场景,用户单击一个按钮来更新驻留在LocalMachine中的注册表项。
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\VisioAddIn",true);
if (setting.Name == "abc")
{
Properties.Settings.Default[setting.Name] = txtbox1.Text;
if (registryKey != null)
registryKey.SetValue("abc", (txtbox1.Text).ToString());
registryKey.Close();
}
if (setting.Name == "def")
{
Properties.Settings.Default[setting.Name] = txtbox2.Text;
if (registryKey != null)
{
registryKey.SetValue("def", (txtbox2.Text).ToString());
registryKey.Close();
}
}
Properties.Settings.Default.Save();
但是出现以下错误System.UnAuthorisedAccessException:无法写入注册表项。
如果我以管理员模式运行visio插件,则不会发生此错误。 但这不是我的解决方案。 请帮帮我。
ish
我不想使用HKCU,因为它可以为所有用户保存(在我的情况下,用户会更多)。我找到了可以提升UAC的解决方案。
链接 !
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.