Use latest version of Internet Explorer in the webbrowser control

后端 未结 13 1397
长发绾君心
长发绾君心 2020-11-21 23:29

The default version of the webbrowser control in a C# Windows Forms application is 7. I have changed to 9 by the article Browser Emulation, but how is it possible t

相关标签:
13条回答
  • 2020-11-22 00:31

    Using the values from MSDN:

      int BrowserVer, RegVal;
    
      // get the installed IE version
      using (WebBrowser Wb = new WebBrowser())
        BrowserVer = Wb.Version.Major;
    
      // set the appropriate IE version
      if (BrowserVer >= 11)
        RegVal = 11001;
      else if (BrowserVer == 10)
        RegVal = 10001;
      else if (BrowserVer == 9)
        RegVal = 9999;
      else if (BrowserVer == 8)
        RegVal = 8888;
      else
        RegVal = 7000;
    
      // set the actual key
      using (RegistryKey Key = Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION", RegistryKeyPermissionCheck.ReadWriteSubTree))
        if (Key.GetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe") == null)
          Key.SetValue(System.Diagnostics.Process.GetCurrentProcess().ProcessName + ".exe", RegVal, RegistryValueKind.DWord);
    
    0 讨论(0)
提交回复
热议问题