如何为Web浏览器默认设置IE9?

use*_*721 1 c# browser

我正在用C#.NET开发一个应用程序.我想将IE9版本用于WebBrowser; IE9是否安装在系统上.

是否有可能将IE9与WebBrower一起使用,而且我的系统中可能没有安装IE9?

vol*_*ody 9

使用Windows Internet Explorer 8或更高版本,FEATURE_BROWSER_EMULATION功能定义Internet Explorer的默认模拟模式.值9999 - 强制网页以IE9标准模式显示,而不管!DOCTYPE指令.您需要在目标系统上安装IE9或更高版本.检查Internet功能控件(B..C)

private static void WebBrowserVersionEmulation()
{
    const string BROWSER_EMULATION_KEY = 
    @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION";
    //
    // app.exe and app.vshost.exe
    String appname = Process.GetCurrentProcess().ProcessName + ".exe";
    //
    // Webpages are displayed in IE9 Standards mode, regardless of the !DOCTYPE directive.
    const int browserEmulationMode = 9999;

    RegistryKey browserEmulationKey =
        Registry.CurrentUser.OpenSubKey(BROWSER_EMULATION_KEY,RegistryKeyPermissionCheck.ReadWriteSubTree) ??
        Registry.CurrentUser.CreateSubKey(BROWSER_EMULATION_KEY);

    if (browserEmulationKey != null)
    {
        browserEmulationKey.SetValue(appname, browserEmulationMode, RegistryValueKind.DWord);
        browserEmulationKey.Close();
    }
}
Run Code Online (Sandbox Code Playgroud)