IE加载ocx时提示控件不安全的解决方法
来源:互联网 发布:佳能ip2880s清零软件 编辑:程序博客网 时间:2024/05/21 15:49
使用MFC 开发的ocx的提示控件不安全的解决方法
1.添加如下的文件在工程中
#include "comcat.h"// Helper function to create a component category and associated// descriptionHRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription);// Helper function to register a CLSID as belonging to a component// categoryHRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid);HRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid);
#include "StdAfx.h"#include "Cathelp.h"HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription){ ICatRegister* pcr = NULL ; HRESULT hr = S_OK ; hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,NULL,CLSCTX_INPROC_SERVER,IID_ICatRegister,(void**)&pcr); if (FAILED(hr))return hr; // Make sure the HKCR/Component Categories/{..catid...} // key is registered CATEGORYINFO catinfo; catinfo.catid = catid; catinfo.lcid = 0x0409 ; // english // Make sure the provided description is not too long. // Only copy the first 127 characters if it is int len = wcslen(catDescription); if (len>127)len = 127; wcsncpy(catinfo.szDescription, catDescription, len); // Make sure the description is null terminated catinfo.szDescription[len] = '/0'; hr = pcr->RegisterCategories(1, &catinfo); pcr->Release(); return hr;}// Helper function to register a CLSID as belonging to a component// categoryHRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid){ // Register your component categories information. ICatRegister* pcr = NULL ; HRESULT hr = S_OK ; hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr,NULL,CLSCTX_INPROC_SERVER,IID_ICatRegister,(void**)&pcr); if (SUCCEEDED(hr)) {// Register this category as being "implemented" by// the class.CATID rgcatid[1] ;rgcatid[0] = catid;hr = pcr->RegisterClassImplCategories(clsid, 1, rgcatid); } if (pcr != NULL)pcr->Release(); return hr;}// HRESULT UnRegisterCLSIDInCategory - Remove entries from the registryHRESULT UnRegisterCLSIDInCategory(REFCLSID clsid, CATID catid){ ICatRegister *pcr = NULL ; HRESULT hr = S_OK ; hr = CoCreateInstance(CLSID_StdComponentCategoriesMgr, NULL, CLSCTX_INPROC_SERVER, IID_ICatRegister, (void**)&pcr); if (SUCCEEDED(hr)) { // Unregister this category as being "implemented" by the class. CATID rgcatid[1] ; rgcatid[0] = catid; hr = pcr->UnRegisterClassImplCategories(clsid, 1, rgcatid); } if (pcr != NULL) pcr->Release(); return hr;}
第二 主文件中添加如下三个值
const CATID CLSID_SafeItem = {0x1f64433, 0x4c9d, 0x4365, {0x83, 0x46, 0x66, 0xae, 0x4f, 0xff, 0x51, 0xa}};const CATID CATID_SafeForScripting = {0x7dd95801,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};const CATID CATID_SafeForInitializing = {0x7dd95802,0x9882,0x11cf,{0x9f,0xa9,0x00,0xaa,0x00,0x6c,0x42,0xc4}};
注意:CLSID_SafeItem的值使用CTL主文件中的IMPLEMENT_OLECREATE_EX的宏值替换而来。格式一定要变,不然不管用。
第三 修改如下两个函数如下:
STDAPI DllRegisterServer(void){ /*AFX_MANAGE_STATE(_afxModuleAddrThis); if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) return ResultFromScode(SELFREG_E_CLASS); return NOERROR;*///NEWÏÂÃæÊÇеÄ×¢²á´úÂë AFX_MANAGE_STATE(_afxModuleAddrThis); if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE)) return ResultFromScode(SELFREG_E_CLASS); if (FAILED( CreateComponentCategory( CATID_SafeForScripting, L"Controls that are safely scriptable") )) return ResultFromScode(SELFREG_E_CLASS); if (FAILED( CreateComponentCategory( CATID_SafeForInitializing, L"Controls safely initializable from persistent data") )) return ResultFromScode(SELFREG_E_CLASS); if (FAILED( RegisterCLSIDInCategory( CLSID_SafeItem, CATID_SafeForScripting) )) return ResultFromScode(SELFREG_E_CLASS); if (FAILED( RegisterCLSIDInCategory( CLSID_SafeItem, CATID_SafeForInitializing) )) return ResultFromScode(SELFREG_E_CLASS); return NOERROR;}/////////////////////////////////////////////////////////////////////////////// DllUnregisterServer - Removes entries from the system registrySTDAPI DllUnregisterServer(void){ /*AFX_MANAGE_STATE(_afxModuleAddrThis); if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) return ResultFromScode(SELFREG_E_CLASS); return NOERROR;*///NEWÏÂÃæÊÇеĴúÂë HRESULT hr; AFX_MANAGE_STATE(_afxModuleAddrThis); // Remove entries from the registry. hr=UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForInitializing); if (FAILED(hr)) return hr; hr=UnRegisterCLSIDInCategory(CLSID_SafeItem, CATID_SafeForScripting); if (FAILED(hr)) return hr; if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor)) return ResultFromScode(SELFREG_E_TYPELIB); if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE)) return ResultFromScode(SELFREG_E_CLASS); return NOERROR; }
好了,没了 ok了
可以参考:
https://support.microsoft.com/zh-cn/kb/161873
http://www.cnblogs.com/lidabo/p/3605495.html
http://blog.csdn.net/u012702039/article/details/43148785
http://www.cnblogs.com/phinecos/archive/2008/08/07/1263270.html
0 0
- IE加载ocx时提示控件不安全的解决方法
- IE加载ocx时提示控件不安全的解决方法
- VB源程序总是提示加载错误,或者不能加载OCX控件解决方法
- Ocx控件在IE滚动时闪烁问题的解决
- 关于OCX控件在ie下调用不了接口的解决方法
- IE浏览器下OCX控件的兼容问题
- IE浏览网页flash.ocx控件加载失败
- 解决IE不能加载OCX控件问题(一)
- 解决IE不能加载OCX控件问题(二)
- IE调试ocx控件
- ocx控件ie调试
- 缺少.ocx等的控件的解决方法
- VB 工程提示不能加载mscomctl.ocx控件错误解决办法
- xp中查找加载的ocx控件
- IE浏览器调用OCX控件的一般方法
- 点击打印出现IE已经阻止此站点用不安全方式使用 ActiveX 控件解决方法
- VC开发的ActiveX加入安全机制,避免IE中提示“在此页上的ActiveX控件,,不安全,你想允许这种交互吗?”
- 网页中"IE限制网页访问脚本或ActiveX控件"的提示问题的解决方法
- Linux基础学习-01
- 图像处理那张熟悉的面孔——Lena
- SenchaTouchq
- JPA注解
- ant
- IE加载ocx时提示控件不安全的解决方法
- C++知识点随笔(七):成员函数指针、模拟虚函数列表
- hdu5301 填满房间最大的矩形的最小值
- UVA129-Krypton Factor
- C++ 文件读写
- 使用Nessus扫描Windows XP SP1之360安全软件
- apache kafka中server.properties配置文件参数说明
- pdf阅读器哪个好
- 关于解决不安全的HTTP方法的验证方案