|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
我想用C++通过COM获得正在运行的CATIA:
::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
HRESULT Result = NOERROR;
CLSID AppClsid;
IUnknown *pAppUnk=NULL;
Result = ::CLSIDFromProgID (L"CATIA.Application", &AppClsid);
Result = ::GetActiveObject (AppClsid, NULL, &pAppUnk);
if (FAILED (Result))
{
return ;
}
CATIAApplication* pAppl = NULL;
pAppUnk->QueryInterface(IID_CATIAApplication, (void**)&pAppl);
pAppUnk->Release(); pAppUnk = NULL;
if(NULL == pAppl)
return;
CATIADocument* pDoc = NULL;
pAppl->get_ActiveDocument(pDoc);
CATIAPartDocument* pPartDoc = NULL;
pDoc->QueryInterface(IID_CATIAPartDocument, (void**)&pPartDoc);
if(NULL == pPartDoc)
{
return;
}
CATIAPart* pPart = NULL;
pPartDoc->get_Part(pPart);
到这儿为止, 都没问题, 但是
CATISpecObject* pSpecOnPart = NULL;
pPart->QueryInterface(IID_CATISpecObject, (void**)&pSpecOnPart);
pSpecOnPart 是空指针. 我只能用Automation的API. 是不是程序错了?或漏了什么? |
|