.net 设置Webbowser 版本
.net 里的Webbowser控件默认情况是用IE7来渲染
可修改注册表试用是最新的版本来渲染:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security;
using Microsoft.Win32;
using System.IO; namespace wgscd
{ public enum BrowserEmulationVersion
{
Default = 0,
Version7 = 7000,
Version8 = 8000,
Version8Standards = 8888,
Version9 = 9000,
Version9Standards = 9999,
Version10 = 10000,
Version10Standards = 10001,
Version11 = 11000,
Version11Edge = 11001
}
public static class WBEmulator
{
private const string InternetExplorerRootKey = @"Software\Microsoft\Internet Explorer"; public static int GetInternetExplorerMajorVersion()
{
int result; result = 0; try
{
RegistryKey key; key = Registry.LocalMachine.OpenSubKey(InternetExplorerRootKey); if (key != null)
{
object value; value = key.GetValue("svcVersion", null) ?? key.GetValue("Version", null); if (value != null)
{
string version;
int separator; version = value.ToString();
separator = version.IndexOf('.');
if (separator != -1)
{
int.TryParse(version.Substring(0, separator), out result);
}
}
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read from the registry key.
}
catch (UnauthorizedAccessException)
{
// The user does not have the necessary registry rights.
} return result;
}
private const string BrowserEmulationKey = InternetExplorerRootKey + @"\Main\FeatureControl\FEATURE_BROWSER_EMULATION"; public static BrowserEmulationVersion GetBrowserEmulationVersion()
{
BrowserEmulationVersion result; result = BrowserEmulationVersion.Default; try
{
RegistryKey key; key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true);
if (key != null)
{
string programName;
object value; programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]);
value = key.GetValue(programName, null); if (value != null)
{
result = (BrowserEmulationVersion)Convert.ToInt32(value);
}
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read from the registry key.
}
catch (UnauthorizedAccessException)
{
// The user does not have the necessary registry rights.
} return result;
}
public static bool SetBrowserEmulationVersion(BrowserEmulationVersion browserEmulationVersion)
{
bool result; result = false; try
{
RegistryKey key; key = Registry.CurrentUser.OpenSubKey(BrowserEmulationKey, true); if (key != null)
{
string programName; programName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); if (browserEmulationVersion != BrowserEmulationVersion.Default)
{
// if it's a valid value, update or create the value
key.SetValue(programName, (int)browserEmulationVersion, RegistryValueKind.DWord);
}
else
{
// otherwise, remove the existing value
key.DeleteValue(programName, false);
} result = true;
}
}
catch (SecurityException)
{
// The user does not have the permissions required to read from the registry key.
}
catch (UnauthorizedAccessException)
{
// The user does not have the necessary registry rights.
} return result;
} public static bool SetBrowserEmulationVersion()
{
int ieVersion;
BrowserEmulationVersion emulationCode; ieVersion = GetInternetExplorerMajorVersion(); if (ieVersion >= 11)
{
emulationCode = BrowserEmulationVersion.Version11;
}
else
{
switch (ieVersion)
{
case 10:
emulationCode = BrowserEmulationVersion.Version10;
break;
case 9:
emulationCode = BrowserEmulationVersion.Version9;
break;
case 8:
emulationCode = BrowserEmulationVersion.Version8;
break;
default:
emulationCode = BrowserEmulationVersion.Version7;
break;
}
} return SetBrowserEmulationVersion(emulationCode);
}
public static bool IsBrowserEmulationSet()
{
return GetBrowserEmulationVersion() != BrowserEmulationVersion.Default;
} } /*
调用 :
* if (!WBEmulator.IsBrowserEmulationSet())
{
WBEmulator.SetBrowserEmulationVersion();
}
*/ }
或者使用第三方的浏览器控件:
项目基于WebKit.NET 0.5开发
google code地址:https://code.google.com/archive/p/open-webkit-sharp/
github网址 : https://github.com/Erls-Corporation/open-webkit-sharp
use the WebKit.NET :https://sourceforge.net/projects/webkitdotnet/
.net 设置Webbowser 版本的更多相关文章
- Composer设置忽略版本匹配的方法
Composer简介 Composer 是 PHP 的一个依赖管理工具.它允许你申明项目所依赖的代码库,它会在你的项目中为你安装他们.Composer 不是一个包管理器.是的,它涉及 "pa ...
- PHP集成环境自定义设置PHP版本,同时运行多个php版本,700个PHP版本随时切换,一键开启常用模块。
本文采用我自己开发的纯绿色版WAMP环境(我将这个WAMP环境命名为PHPWAMP) (PHPWAMP默认集成VC,不需要单独安装) 那么什么是WAMP环境?WAMP这个词是什么意思? Windows ...
- composer设置忽略版本匹配
composer install 时遇到错误: Your requirements could not be resolved to an installable set of packages. 原 ...
- GreenDao设置数据版本
GreenDao设置数据库版本增加后,会自动删除并创建新数据库,将SCHEMA_VERSION增加即可. 在3.0里可以在config配置里进行设置 apply plugin: 'com.androi ...
- PyCharm设置Python版本
PyCharm默认会使用虚拟的Python解释器,即使没有安装也能够运行Python代码,但有强迫症的程序员一定不能忍受Project中存在这么多的文件目录 设置Python版本 File->S ...
- 解决java.io.IOException: Cannot run program "javac"问题,并设置jdk版本
原因:没有配置java路径 解决方法:设置java_home路径 设置jdk版本是10的方法:在sbt文件中添加一行: javacOptions := Seq(") 然后重新执行命令:sbt ...
- C#程序集系列08,设置程序集版本
区别一个程序集,不仅仅是程序集名称,还包括程序集版本.程序集公匙.程序集文化等,本篇体验通过界面和编码设置程序集版本. □ 通过Visual Studio设置程序集版本 →右键项目,选择"属 ...
- PyCharm设置Python版本,你肯定不知道!
前言本文的文字及图片来源于网络,仅供学习.交流使用,不具有任何商业用途,版权归原作者所有,如有问题请及时联系我们以作处理.作者:智小星 PyCharm默认会使用虚拟的Python解释器,即使 ...
- eclipse配置JDK和设置编译版本的几种方法
eclipse配置JDK和设置编译版本的几种方法 2016-12-13 16:08 http://blog.csdn.net/gnail_oug/article/detail ...
随机推荐
- jQuery事件和JSON点语法
<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" ...
- Just write about
创建一个学生对象,存储学生对象,学生对象的数据来源于键盘录入,最后遍历集合. 学生类,集合对象,键盘录入数据并将数据赋值给学生类的成员(可以写成一个方法),调用方法,遍历集合.
- LeetCode 题解之 Positions of Large Groups
1.题目描述 2.问题分析 从头遍历字符串,使用一个局部迭代器和局部变量记录该字符个数.如果个数>= 3 ,则将此时的迭代器位置和局部迭代器的位置保存到局部vector中.再将这个局部vecto ...
- 软件工程-XP方法十二个最佳实践
- Oracle EBS INV 创建物料搬运单
Create or Replace PROCEDURE ProcessMoveOrder AS -- Common Declarations l_api_version NUMBER := 1.0; ...
- Visual Studio 2010详细安装过程
Visual Studio 2010在目前看来,应该是使用得比较多的一款微软的软件开发工具集合了,因为它具有以下优点:(1)启动速度快:在相同环境下,相比于Visual Studio 2015来说,2 ...
- 美团SQL优化工具SQLAdvisor
介绍 在数据库运维过程中,优化 SQL 是 DBA 团队的日常任务.例行 SQL 优化,不仅可以提升程序性能,还能够降低线上故障的概率. 目前常用的 SQL 优化方式包括但不限于:业务层优化.SQL逻 ...
- PowerShell发送邮件(587)
#定义邮件服务器 $smtpServer = "mail.xx.com" $smtpUser = "sender" $smtpPassword = " ...
- 常用的 接口访问方法 post 和get
public string GetFunction(string serviceAddress) { HttpWebRequest request = (HttpWebRequest)WebReque ...
- 1 什么是virtual Machine
1.所有的虚拟机以文件的形式存放在存储上. 2.虚拟机的文件构成: swap files: <vm_name>.vswp 虚拟机的内存文件,vmx-<vm_name>.vsw ...