设置webbrowser浏览器内核

var hklm = Microsoft.Win32.Registry.LocalMachine;
            var lmRun64 = hklm.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
            var lmRun32 = hklm.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true);
            //获取路径的方法
            string location64 = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName;
            string fileName64 = System.IO.Path.GetFileName(location64);
            string location32 = this.GetType().Assembly.Location;
            string fileName32 = System.IO.Path.GetFileName(location32);
            if (lmRun64 != null)
            {
                string value64 = null;

                var xx = lmRun64.GetValue(fileName64);
                if (xx != null)
                {
                    value64 = Convert.ToString(lmRun64.GetValue(fileName64));
                }
                if (string.IsNullOrEmpty(value64))
                {
                    //lmRun64.SetValue("TemplateBrowser.exe", 0x2710); //设置webbrowser调用IE10内核打开
                    lmRun64.SetValue(fileName64, 0x2710); //设置webbrowser调用IE10内核打开
                    lmRun64.SetValue(fileName32, 0x2710); //设置webbrowser调用IE10内核打开
                }

            }

            if (lmRun32 != null)
            {
                string value32 = null;
                var xx = lmRun32.GetValue(fileName32);
                if (xx != null)
                {
                    value32 = Convert.ToString(lmRun32.GetValue(fileName32));
                }

                if (string.IsNullOrEmpty(value32))
                {
                    //lmRun32.SetValue("TemplateBrowser.exe", 0x2710); //设置webbrowser调用IE10内核打开
                    lmRun32.SetValue(fileName32, 0x2710); //设置webbrowser调用IE10内核打开
                    lmRun32.SetValue(fileName64, 0x2710); //设置webbrowser调用IE10内核打开
                }
            }


            wb.Url = new Uri("http://www.dcwriter.cn/");

转载于:https://www.cnblogs.com/edangame/p/5468788.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值