分享

指定Webbrowser控件内核版本的方案

 kingjae 2015-05-27

方法一

加入你想让WebBrowser控件的渲染模式编程IE8的标准模式, 你可以通过设置注册表FEATURE_BROWSER_EMULATION 来实现。

示例:

注册表中注明当前本机装的IE版本
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer
下面有名称为Version的项,其值为IE的版本.
svcVersion =10.0.9200.16618
Version =9.10.9200.16618

[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION] 
"MyApplication.exe" = dword 8000 (Hex: 0x1F40)

这里MyApplicaiton.exe 是你的应用程序的EXE文件名。 8000 表示8.0的渲染模式,请对照下表:

IE8 Standards Mode   8000 (0x1F40)  -- IE8 标准模式 (Standard Mode) IE8默认的模式

IE7 Standards Mode   7000 (0x1B58)  -- IE7 兼容视图模式 (Compatible View)IE8WebBrowser控件默认模式

IE8 Standards Mode (Forced)  8888 (0x22B8) -- IE8 强制标准模式,在渲染失败的情况下不尝试用兼容视图模式

 方法二

 在html头 加标签 强制使用最新的ie渲染 <meta http-equiv="X-UA-Compatible" content="IE=edge">

强制使用最新的ie8渲染<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>

 

修改案例:

 

 
void WINAPI WriteWebBrowserRegKey(LPCTSTR lpKey,DWORD dwValue)
{
    HKEY hk;
    CString str = "Software\\Microsoft\\Internet Explorer\\Main\\FeatureControl\\";
    str += lpKey;
    if (RegCreateKey(HKEY_LOCAL_MACHINE,str,&hk)!=0)
    {
        MessageBox(NULL,"打开注册表失败!","Error",0);
        ExitProcess(-1);
    }
    if (RegSetValueEx(hk,"你的exe名称.exe",NULL,REG_DWORD,(const byte*)&dwValue,4)!=0)
    {
        RegCloseKey(hk);
        MessageBox(NULL,"写注册表失败!","Error",0);
        ExitProcess(-1);
    }
    RegCloseKey(hk);
}
 

 

 
        WriteWebBrowserRegKey("FEATURE_BROWSER_EMULATION",9000);
        //WriteWebBrowserRegKey("FEATURE_ACTIVEX_REPURPOSEDETECTION",1);
        WriteWebBrowserRegKey("FEATURE_BLOCK_LMZ_IMG",1);
        WriteWebBrowserRegKey("FEATURE_BLOCK_LMZ_OBJECT",1);
        WriteWebBrowserRegKey("FEATURE_BLOCK_LMZ_SCRIPT",1);
        WriteWebBrowserRegKey("FEATURE_Cross_Domain_Redirect_Mitigation",1);
        WriteWebBrowserRegKey("FEATURE_ENABLE_SCRIPT_PASTE_URLACTION_IF_PROMPT",1);
        WriteWebBrowserRegKey("FEATURE_LOCALMACHINE_LOCKDOWN",1);
        WriteWebBrowserRegKey("FEATURE_GPU_RENDERING",1);
 

 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多