public enum IeVersion
{
IE7 = ,
IE8 = ,
IE9 = ,
IE10 = ,
IE11 =
};
/// <summary>
/// 修改注册表信息来兼容当前程序
/// </summary>
public static void SetWebBrowserFeatures(IeVersion ieVersion)
{
if (LicenseManager.UsageMode != LicenseUsageMode.Runtime) return;
//获取程序及名称
string AppName = System.IO.Path.GetFileName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName);
//得到浏览器的模式的值
UInt32 ieMode = GeoEmulationModee((int)ieVersion);
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, , RegistryValueKind.DWord);
Registry.SetValue(featureControlRegKey + "FEATURE_AJAX_CONNECTIONEVENTS", AppName, , RegistryValueKind.DWord);
Registry.SetValue(featureControlRegKey + "FEATURE_GPU_RENDERING", AppName, , RegistryValueKind.DWord);
Registry.SetValue(featureControlRegKey + "FEATURE_WEBOC_DOCUMENT_ZOOM", AppName, , RegistryValueKind.DWord);
Registry.SetValue(featureControlRegKey + "FEATURE_NINPUT_LEGACYMODE", AppName, , RegistryValueKind.DWord);
}
/// <summary>
/// 通过版本得到浏览器模式的值
/// </summary>
/// <param name="browserVersion"></param>
/// <returns></returns>
private static UInt32 GeoEmulationModee(int browserVersion)
{
UInt32 mode = ; // Internet Explorer 11. Webpages containing standards-based !DOCTYPE directives are displayed in IE11 Standards mode.
switch (browserVersion)
{
case :
mode = ; // Webpages containing standards-based !DOCTYPE directives are displayed in IE7 Standards mode.
break;
case :
mode = ; // Webpages containing standards-based !DOCTYPE directives are displayed in IE8 mode.
break;
case :
mode = ; // Internet Explorer 9. Webpages containing standards-based !DOCTYPE directives are displayed in IE9 mode.
break;
case :
mode = ; // Internet Explorer 10.
break;
case :
mode = ; // Internet Explorer 11
break;
}
return mode;
}