新手急问: 关于IE下载控件的问题

coppermine 2003-03-29 05:05:57
我用VC写了一个简单的自动化组件嵌在网页内,但每次浏览该网页总是出现以下提示信息:

“在此页上的ActiveX控件可能和本页上的其它部件的交流不安全,你想允许这种交流吗?”

请问大虾该如何解决?? 解决后保证给分!!
...全文
65 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
coppermine 2003-03-29
搞定了,给分!
回复
handsomebaby 2003-03-29
要实现两个接口,初始化安全化接口和脚本安全话接口!

如果用ATL则加入:

BEGIN_CATEGORY_MAP(CMyControl)
IMPLEMENTED_CATEGORY(CATID_SafeForInitializing)
IMPLEMENTED_CATEGORY(CATID_SafeForScripting)
END_CATEGORY_MAP()

MFC要改哪个UPDATEREISTER

UpdateRegistry(BOOL bRegister)
{

if (bRegister)
{
BOOL retval = AfxOleRegisterControlClass(
AfxGetInstanceHandle(),
m_clsid,
m_lpszProgID,
IDS_MADMETHODCALL,
IDB_MADMETHODCALL,
afxRegApartmentThreading,
_dwMadMethodCallOleMisc,
_tlid,
_wVerMajor,
_wVerMinor);
// mark as safe for scripting--failure OK
HRESULT hr = CreateComponentCategory(CATID_SafeForScripting,
L"Controls that are safely scriptable");

if (SUCCEEDED(hr))
// only register if category exists
RegisterCLSIDInCategory(m_clsid, CATID_SafeForScripting);
// don't care if this call fails

// mark 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;
}
else
{
return AfxOleUnregisterClass(m_clsid, m_lpszProgID);
}
}
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;
}
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;
}
回复
coppermine 2003-03-29
我把该网页所在的站点设为“可信站点”,但还是出现这个问题。
回复
发帖
ATL
创建于2007-09-28

3214

社区成员

ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
申请成为版主
帖子事件
创建了帖子
2003-03-29 05:05
社区公告
暂无公告