C# 在web浏览器桌面应用程序中访问注册表时出错
我正在开发web浏览器应用程序。许多网站运行正常,但其中一些网站会更新flipkart.com网站等浏览器。因此,我在最新的ie浏览器中为工作网站创建注册表项,但在该错误中显示“访问注册表时出错”。请帮我解决这个错误。这是我的密码C# 在web浏览器桌面应用程序中访问注册表时出错,c#,C#,我正在开发web浏览器应用程序。许多网站运行正常,但其中一些网站会更新flipkart.com网站等浏览器。因此,我在最新的ie浏览器中为工作网站创建注册表项,但在该错误中显示“访问注册表时出错”。请帮我解决这个错误。这是我的密码 private void Form1_Load(object sender, EventArgs e) { Helper.SetBrowserEmulation(AppDomain.CurrentDomain.FriendlyName, IE.IE10); }
private void Form1_Load(object sender, EventArgs e)
{
Helper.SetBrowserEmulation(AppDomain.CurrentDomain.FriendlyName, IE.IE10);
}
internal class Helper
{
public static void SetBrowserEmulation(
string programName, IE browserVersion)
{
programName = AppDomain.CurrentDomain.FriendlyName;
RegistryKey regKey = Registry.CurrentUser.OpenSubKey(
"Software\\Microsoft\\Internet Explorer\\Main" +
"\\FeatureControl\\FEATURE_BROWSER_EMULATION", true);
if (regKey != null)
{
try
{
regKey.SetValue(programName, browserVersion,
RegistryValueKind.DWord);
}
catch (Exception ex)
{
throw new Exception("Error writing to the registry", ex);
}
}
else
{
try
{
regKey = Registry.CurrentUser.OpenSubKey("Software" +
"\\Microsoft\\Internet Explorer\\Main" +
"\\FeatureControl", true);
regKey.CreateSubKey("FEATURE_BROWSER_EMULATION");
regKey.SetValue(programName, browserVersion,
RegistryValueKind.DWord);
}
catch (Exception ex)
{
throw new Exception("Error accessing the registry", ex);
}
}
}
}
internal enum IE
{
IE7 = 7000,
IE8 = 8000,
IE8StandardsMode = 8888,
IE9 = 9000,
IE9StandardsMode = 9999,
IE10 = 10000,
IE10StandardsMode = 10001
}
private void GoButton_Click(object sender, EventArgs e)
{
string WebPage = UrlTextBox.Text.Trim();
webBrowser1.Navigate(WebPage);
}