你可能在看ATL开发指南,这个函数不是VC的库函数,而是一个自己编写的函数。
一下是它的实现代码:
HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{
ICatRegister* pcr = 0;
HRESULT hr;
hr = CoCreateInstance( CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr );
if (FAILED(hr))
return hr; CATEGORYINFO catinfo;
catinfo.catid = catid;
catinfo.lcid = 0x0409;
int len = wcslen( catDescription );
wcsncpy( catinfo.szDescription, catDescription, wcslen( catDescription ));
catinfo.szDescription[len] = '\0'; hr = pcr->RegisterCategories( 1, &catinfo );
pcr->Release(); return hr;
}
一下是它的实现代码:
HRESULT CreateComponentCategory(CATID catid, WCHAR* catDescription)
{
ICatRegister* pcr = 0;
HRESULT hr;
hr = CoCreateInstance( CLSID_StdComponentCategoriesMgr,
NULL,
CLSCTX_INPROC_SERVER,
IID_ICatRegister,
(void**)&pcr );
if (FAILED(hr))
return hr; CATEGORYINFO catinfo;
catinfo.catid = catid;
catinfo.lcid = 0x0409;
int len = wcslen( catDescription );
wcsncpy( catinfo.szDescription, catDescription, wcslen( catDescription ));
catinfo.szDescription[len] = '\0'; hr = pcr->RegisterCategories( 1, &catinfo );
pcr->Release(); return hr;
}
还有一个函数RegisterCLSIDInCategory也是如此吗?
{
// Register your component categories information.
ICatRegister* pcr = 0;
HRESULT hr;
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 ); pcr->Release();
} return hr;
}