//////////////////////////////////////////////////////////////////////////// // // Written by George Cross, Borland C++ Developer Support, July 1997 // // Copyright (c) 1997 Borland International Inc. All Rights Reserved. // #include #include #include #include #define BUFFERSIZE 256 //////////////////////////////////////////////////////////////////////////// // I put these GUIDs in since they weren't correct in import32.lib. extern "C" const GUID CLSID_StdComponentCategoriesMgr = {0x0002e005,0x0000,0x0000,{0xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; extern "C" const GUID IID_ICatRegister = {0x0002E012,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; extern "C" const GUID IID_ICatInformation = {0x0002E013,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}}; //////////////////////////////////////////////////////////////////////////// void HandleError(_TCHAR* pszMsg = 0, DWORD dwMsgID = GetLastError()) { if (pszMsg){ _tprintf(pszMsg); } else{ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, NULL, dwMsgID, 0, (LPTSTR)&pszMsg, 0, NULL); _tprintf(pszMsg); LocalFree(pszMsg); } _gettchar(); OleUninitialize(); return; } //////////////////////////////////////////////////////////////////////////// extern "C" void _tmain(int, _TCHAR* /* argv[] */) { HRESULT hr; ICatRegister* pcatReg; ICatInformation* pcatInfo; IClassFactory* pCF; if (FAILED(OleInitialize(NULL))){ _tprintf(_TEXT("OleInitialize() failed.\n")); } hr=CoGetClassObject(CLSID_StdComponentCategoriesMgr, CLSCTX_INPROC_SERVER, NULL, IID_IClassFactory, &static_cast(pCF)); if (FAILED(hr)){ HandleError(0, hr); return; } hr=pCF->CreateInstance(NULL,IID_ICatRegister, &static_cast(pcatReg)); if (FAILED(hr)){ HandleError(0, hr); return; } _tprintf(_TEXT("IID_CatRegister obtained. Press any key to release interface.\n")); _gettchar(); pcatReg->Release(); hr=pCF->CreateInstance(NULL,IID_ICatInformation, &static_cast(pcatInfo)); if (FAILED(hr)){ HandleError(0, hr); return; } _tprintf(_TEXT("IID_CatInformation obtained. Press any key to release interface.\n")); _gettchar(); pcatInfo->Release(); pCF->Release(); OleUninitialize(); return; }