winfrom中的webbrowser内核版本修改
2021-06-18 04:07
标签:ide server == webp rect 应用程序 pen explore 修改 vs2008,winfrom中的webbrowser 其内核默认为IE7,当网页中存在IE7不支持的属性时回报错。 winfrom中的webbrowser内核版本修改 标签:ide server == webp rect 应用程序 pen explore 修改 原文地址:https://www.cnblogs.com/lq0418/p/10312693.html
private void Form1_Load(object sender, EventArgs e)
{
SetWebBrowserFeatures(11);
}
static void SetWebBrowserFeatures(int ieVersion)
{
// don‘t change the registryif running in-proc inside Visual Studio
if (LicenseManager.UsageMode != LicenseUsageMode.Runtime) return;
//获取程序及名称
var appName = System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
//得到浏览器的模式的值
UInt32 ieMode = GeoEmulationModee(ieVersion);
var featureControlRegKey = @"HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Main\FeatureControl\";
//设置浏览器对应用程序(appName)以什么模式(ieMode)运行
Registry.SetValue(featureControlRegKey + "FEATURE_BROWSER_EMULATION", appName, ieMode, RegistryValueKind.DWord);
// enable the features which are "On" for the full Internet Explorer browser //不晓得设置有什么用
Registry.SetValue(featureControlRegKey + "FEATURE_ENABLE_CLIPCHILDREN_OPTIMIZATION", appName, 1, RegistryValueKind.DWord);
}
static int GetBrowserVersion()
{
int browserVersion = 0;
using (var ieKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer", RegistryKeyPermissionCheck.ReadSubTree, System.Security.AccessControl.RegistryRights.QueryValues)) { var version = ieKey.GetValue("svcVersion");
if (null == version)
{
version = ieKey.GetValue("Version");
if (null == version) throw new ApplicationException("Microsoft Internet Explorer is required!");
}
int.TryParse(version.ToString().Split(‘.‘)[0], out browserVersion); } //如果小于7
if (browserVersion
上一篇:API接口幂等性框架设计
下一篇:日期时间API