技术开发 频道

步步学ACTIVEX网页控件开发:创建安全的ActiveX控件

  注册组件分类信息
 

//      注册组件分类信息


HRESULT RegisterCLSIDInCategory(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))
    {
       CATID rgcatid[
1] ;
       rgcatid[
0] = catid;
       hr
= pcr->RegisterClassImplCategories(clsid, 1, rgcatid);
    }

    
if (pcr != NULL)
        pcr
->Release();
            
    
return hr;
}

// HRESULT UnRegisterCLSIDInCategory

HRESULT 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))
    {
       CATID rgcatid[
1] ;
       rgcatid[
0] = catid;
       hr
= pcr->UnRegisterClassImplCategories(clsid, 1, rgcatid);
    }

    
if (pcr != NULL)
        pcr
->Release();

    
return hr;
}
0
相关文章