正在为我的应用程序开发一个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插件,则不会发生此错误。但它不是我的解决方案。请帮帮我。
哈里什