- 1
- 0
- 约1.2万字
- 约 11页
- 2017-08-11 发布于重庆
- 举报
web上用Activex控件开发步骤(MFC)
web上用Activex控件开发步骤(MFC)
首先要说明的是 web上用activex是门被抛弃的技术。为什么这么说,主要基于以下几个原因:1.功能过于强大,强大到一旦安装,他所具有的权限可以做任何事,极易被人利用做坏事(相信大家都有浏览网页后莫名被安装流氓软件的经历,当然流氓软件利用的方式不止控件一种);2。通过网页下载控件的中间过程受到操作系统、杀毒软件、浏览器等多方面因素限制,这使你的控件产品未必能在所有用户的电脑上正常使用;3。最恶心的一点,未签名没有正规安全证书的控件,在最新的浏览器上(IE7等)默认安全策略是直接屏蔽掉的,而你如果想要获取这个信任,需要向微软等少数单位申请,花费有多少?据说是每年4千多。。。
看了以上如果你还是想要知道步骤,如下:
一。用Vc++6.0新建工程里的向导创建MFC activeX controlWizard,细节不说了,根据你控件需要了,略有不同,问题不会太大。
二。你控件代码的主xx.cpp(非xxCtr.cpp)文件中添加安全接口函数,否则每次运行控件时IE都会给出安全提示,很烦!
#include comcat.h
#include Objsafe.h
// 本控件的CLSID,注册表用
const GUID CDECL CLSID_SafeItem ={ 0x7AE7497B, 0xCAD8, 0x4E66,
{ 0xA5,0x8B,0xDD,0xE9,0xBC,0xAF,0x6B,0x61 } };
// 版本控制
const WORD _wVerMajor = 1;
// 次版本号
const WORD _wVerMinor = 0;
/////////////////////////////////////////////////////////////////////
// CICCardApp::InitInstance - DLL initialization
BOOL CICCardApp::InitInstance()
{
BOOL bInit = COleControlModule::InitInstance();
if (bInit)
{
}
return bInit;
}
//////////////////////////////////////////////////////////////////////
// CICCardApp::ExitInstance - DLL termination
int CICCardApp::ExitInstance()
{
return COleControlModule::ExitInstance();
}
//////////////////////////////////////////////////////////////////////
// 创建组件种类
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 (len127)
len = 127;
wcsncpy(catinfo.szDescription, catDescription, len);
//
原创力文档

文档评论(0)