c# C#设置WebBrowser使用Edge内核

摘要:
起初,我尝试使用Microsoft.Toolkit.Forms.UI.Controls.WebView。后来,我发现了很多问题,还需要WIN10 SDK版本。在线看到的简单解决方案(只需要修改注册表)(前提是win10系统需要安装Edge浏览器):此功能是在线复制的,传入的11000是IE119000是IE9。然而,当试图转移6000时,它应该是IE6,但实际上是Edge。此时,进一步测试,当传入

开始尝试是用 Microsoft.Toolkit.Forms.UI.Controls.WebView,后来发现一大堆问题,还要求WIN10 SDK的版本之类的。

网上看到的简单的解决办法(只需要修改注册表)(前提是win10系统需要安装Edge浏览器):

这个函数是网上复制的, 传入11000是IE11, 9000是IE9, 只不过当试着传入6000时, 理应是IE6, 可实际却是Edge, 这时进一步测试, 当传入除IE现有版本以外的一些数值时WebBrowser都使用Edge内核

结论

将IE版本号设置为非IE版本的数值就能使用Edge内核
这个方法目前不知道原理, 并且也没有测试过稳定性, 以上内容仅供参考

using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace TestEdgeWebBrowser
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            SetFeatures(6000);
            InitializeComponent();
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            web.Navigate("https://liulanmi.com/labs/core.html");
        }

        /// <summary>
        /// 修改注册表信息使WebBrowser使用指定版本IE内核
        /// </summary>
        public static void SetFeatures(UInt32 ieMode)
        {
            if (LicenseManager.UsageMode != LicenseUsageMode.Runtime)
            {
                throw new ApplicationException();
            }
            //获取程序及名称
            string appName = System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
            string featureControlRegKey = "HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\";
            //设置浏览器对应用程序(appName)以什么模式(ieMode)运行
            Registry.SetValue(featureControlRegKey + "FEATURE_BROWSER_EMULATION", appName, ieMode, RegistryValueKind.DWord);
            //不晓得设置有什么用
            Registry.SetValue(featureControlRegKey + "FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", appName, 1, RegistryValueKind.DWord);
        }
    }
}

  

参考:https://blog.csdn.net/xy1157/article/details/103203545

免责声明:文章转载自《c# C#设置WebBrowser使用Edge内核》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Zookeeper 3.5.7搭建(启用Kerberos)SpringBoot实现JWT认证下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

IE 浏览器各个版本 JavaScript 支持情况一览表

摘自:http://www.open-open.com/lib/view/open1387415311921.html 不同版本的 Internet Explorer 浏览器支持不同的 JavaScript 元素集。标准模式(有 <!doctype> 指令时 Internet Explorer 所有当前版本中使用的模式)支持的一组元素与突发模式...

Edge Extraction 边缘提取

1. 一般过程 ******************************************** *   sobel_amp(Image : EdgeAmplitude : FilterType, Size : ) *   不能完全排除虚假边缘,检测出的结果容易出现多像素边缘 *   sobel算子由两个卷积核组成 *          ...

Ajax的完整兼容各种浏览器版本代码

<script type="text/javascript"> function createAjax(){var request=false;//window对象中有XMLHttpRequest存在就是非IE,有可能是(IE7,IE8)if(window.XMLHttpRequest){request=new XMLHttpRequest()...

IE和Firefox的兼容问题

IE和Firefox的兼容问题 本文摘自:http://blog.csdn.net/powerglover/archive/2009/01/15/3789631.aspx 1、Event的问题 在ie中我们可以直接使用event变量,但是在firefox下由于event是局部变量,firefox下我们可以事件绑定到元素上 例如 <input type...

Delphi调用IE打开网页

//调用相应程序打开   uses ShellAPI;   procedure TForm1.Button1Click(Sender: TObject);   begin   //用IE打开   ShellExecute(Handle, 'open', 'IExplore.EXE', 'about:blank', nil, SW_SHOWNORMAL);...

IE下设置SELECT项不可选

因为最近在用jquery 所以JS是Jquery格式写的 代码 1<selectname="drpADAddress"id="drpADAddress">2<optionvalue="0">请选择</option>3<optionvalue="0"disabled="true">首页</option&...