• c# C#设置WebBrowser使用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

    fffffffffffffffff
    test red font.
  • 相关阅读:
    Excel导出
    上传进度基础
    git基本使用
    git学习记录
    Composer 扩展包安装方法
    selected多次点击不生效
    ajaxFileUpload的data数据带pre标签
    php-resque 简单的php消息队列
    git checkout 报错 refname 'origin/branch-name' is ambiguous
    MySQL单独存放表空间Innodb_file_per_table
  • 原文地址:https://www.cnblogs.com/wgscd/p/14393386.html
Copyright © 2020-2023  润新知