//设置IE版本 bool CPlazaBrowser::SetIECoreVersion(long lIEversion) { //提权 HANDLE TokenHandle; TOKEN_PRIVILEGES t_privileges = {0}; if(!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES|TOKEN_QUERY, &TokenHandle)) { ASSERT(FALSE); return FALSE; } if(!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &t_privileges.Privileges[0].Luid)) { ASSERT(FALSE); return TRUE; } t_privileges.PrivilegeCount = 1; t_privileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if(!AdjustTokenPrivileges(TokenHandle, FALSE, &t_privileges, sizeof(TOKEN_PRIVILEGES), NULL, NULL)) { CloseHandle(TokenHandle); ASSERT(FALSE); return FALSE; } //程序名称 TCHAR szAppPath[MAX_PATH] = { 0 }; GetModuleFileName(NULL, szAppPath, MAX_PATH); LPTSTR lpszTemp =PathFindFileName(szAppPath); //设置IE版本 wchar_t* path = TEXT("SOFTWARE\\Microsoft\\Internet Explorer\\MAIN\\FeatureControl\\FEATURE_BROWSER_EMULATION"); wchar_t* valueName =lpszTemp; wchar_t err[1024]={0}; HKEY hKey; DWORD dwDisposition; long ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, path, 0,REG_LEGAL_OPTION, &hKey); if( ret != ERROR_SUCCESS) { FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, ret, NULL,err,sizeof(err),NULL); ret = RegCreateKeyEx(HKEY_LOCAL_MACHINE, path,0, NULL, REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL, &hKey, &dwDisposition); if( ret != ERROR_SUCCESS) { FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, ret, NULL,err,sizeof(err),NULL); ASSERT(FALSE); return FALSE; } } ret = RegSetValueEx( hKey, valueName, NULL, REG_DWORD, (BYTE*)&lIEversion, sizeof(lIEversion)); if( ret != ERROR_SUCCESS) { ASSERT(FALSE); return FALSE; } return TRUE; /* 10001 (0x2711) Internet Explorer 10。网页以IE 10的标准模式展现,页面!DOCTYPE无效 10000 (0x02710) Internet Explorer 10。在IE 10标准模式中按照网页上!DOCTYPE指令来显示网页。Internet Explorer 10 默认值。 9999 (0x270F) Windows Internet Explorer 9. 强制IE9显示,忽略!DOCTYPE指令 9000 (0x2328) Internet Explorer 9. Internet Explorer 9默认值,在IE9标准模式中按照网页上!DOCTYPE指令来显示网页。 8888 (0x22B8) Internet Explorer 8,强制IE8标准模式显示,忽略!DOCTYPE指令 8000 (0x1F40) Internet Explorer 8默认设置,在IE8标准模式中按照网页上!DOCTYPE指令展示网页 7000 (0x1B58) 使用WebBrowser Control控件的应用程序所使用的默认值,在IE7标准模式中按照网页上!DOCTYPE指令来展示网页。 6000 //浏览器标识 #define IE_VERSION60 6000 //IE6 #define IE_VERSION70 7000 //IE7 #define IE_VERSION80 8000 //IE8 #define IE_VERSION88 8888 //IE8 #define IE_VERSION90 9000 //IE9 #define IE_VERSION99 9999 //IE9 #define IE_VERSION10 10000 //IE10 #define IE_VERSION11 10001 //IE10 */ }