终于找到了.不敢独享.
MFC 写的ActiveX 的修改.或者参照:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaxctrl/html/msdn_abcsmfc.asp//具体修改内容
/*--------------------------C****Ctrl.cpp-------------------------*/
#include "helpers.h" //文件内容再下面
#include <objsafe.h>BOOL C****Ctrl::C****CtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0. if (bRegister){
BOOL retval = AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_MFCSAFE,
IDB_MFCSAFE,
afxRegApartmentThreading,
_dwMfcsafeOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
HRESULT hr = CreateComponentCategory(CATID_SafeForScripting,
L"Controls that are safely scriptable");
/*------------------------Safe--------------------------*/
if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForScripting);
// don't care if this call fails // as safe for data initialization
hr = CreateComponentCategory(CATID_SafeForInitializing,
L"Controls safely initializable from persistent data"); if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForInitializing);
// don't care if this call fails return retval;
/*------------------------Safe--------------------------*/
}
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}/*--------------------------****Ctrl.cpp-------------------------*/
/*-------------------------helpers.h----------------------------*/
// Helpers.h : Declarations of object safety category helper functions#include "comcat.h"HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription);
HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid);
/*-------------------------helpers.h----------------------------*//*-------------------------helpers.cpp----------------------------*/// Helpers.cpp : Implementation of of object safety category helper functions
// Copied from ActiveX SDK#include "stdafx.h"#include "helpers.h"/////////////////////////////////////////////////////////////////////////////
// CreateComponentCategory - Ensures component category exists in registry
// (Copied from ActiveX SDK docs)HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{ ICatRegister* pcr = NULL ; // interface pointer
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;
}/////////////////////////////////////////////////////////////////////////////
// RegisterCLSIDInCategory - Registers class clsid as implementing category catid
// (Copied from ActiveX SDK docs)HRESULT 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;
}/*-------------------------helpers.cpp----------------------------*/
MFC 写的ActiveX 的修改.或者参照:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaxctrl/html/msdn_abcsmfc.asp//具体修改内容
/*--------------------------C****Ctrl.cpp-------------------------*/
#include "helpers.h" //文件内容再下面
#include <objsafe.h>BOOL C****Ctrl::C****CtrlFactory::UpdateRegistry(BOOL bRegister)
{
// TODO: Verify that your control follows apartment-model threading rules.
// Refer to MFC TechNote 64 for more information.
// If your control does not conform to the apartment-model rules, then
// you must modify the code below, changing the 6th parameter from
// afxRegApartmentThreading to 0. if (bRegister){
BOOL retval = AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_MFCSAFE,
IDB_MFCSAFE,
afxRegApartmentThreading,
_dwMfcsafeOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
HRESULT hr = CreateComponentCategory(CATID_SafeForScripting,
L"Controls that are safely scriptable");
/*------------------------Safe--------------------------*/
if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForScripting);
// don't care if this call fails // as safe for data initialization
hr = CreateComponentCategory(CATID_SafeForInitializing,
L"Controls safely initializable from persistent data"); if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForInitializing);
// don't care if this call fails return retval;
/*------------------------Safe--------------------------*/
}
else
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}/*--------------------------****Ctrl.cpp-------------------------*/
/*-------------------------helpers.h----------------------------*/
// Helpers.h : Declarations of object safety category helper functions#include "comcat.h"HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription);
HRESULT RegisterCLSIDInCategory(REFCLSID clsid, CATID catid);
/*-------------------------helpers.h----------------------------*//*-------------------------helpers.cpp----------------------------*/// Helpers.cpp : Implementation of of object safety category helper functions
// Copied from ActiveX SDK#include "stdafx.h"#include "helpers.h"/////////////////////////////////////////////////////////////////////////////
// CreateComponentCategory - Ensures component category exists in registry
// (Copied from ActiveX SDK docs)HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{ ICatRegister* pcr = NULL ; // interface pointer
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;
}/////////////////////////////////////////////////////////////////////////////
// RegisterCLSIDInCategory - Registers class clsid as implementing category catid
// (Copied from ActiveX SDK docs)HRESULT 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;
}/*-------------------------helpers.cpp----------------------------*/
解决方案 »
- LNK LNK哪里错了?
- 哪里有介绍Direct UI的资料啊?
- 一台主机如何加入到两个或者以上的组播组呢
- ASSERT(pState->m_hSocketWindow != NULL);出错了?
- 请问一下WSAStartup()是不是包含在winsocket.h头文件里?
- 求助:多重视图的读取
- 前辈们请进,小弟遇到点棘手的硬软件问题,希望得到帮助!!(up有分!!)
- 急!!!请问在英文WINNT4下用什么软件可以实现屏幕翻译?可以加分。
- OpenGL的弱问题
- SQL SERVER 数据库的小问题
- 400分求助:可供BCB调用的VC DLL应该怎么写?
- IE插件是不是要用到ActiveX技术?
运行后,还是出现安全提示。另外:BOOL C****Ctrl::C****CtrlFactory::UpdateRegistry(BOOL bRegister)中
IDS_MFCSAFE,
IDB_MFCSAFE,
_dwMfcsafeOleMisc,
这三个系统报未定义错,我用原来的替换了。