|
我在对CAXA工艺图表2011进行二次开发,参考你之前贴子中的代码: HRESULT hRet;
CLSID clsid;
ICAPPInfo *pInterface = NULL;
ICAPPXmlInfo *pXmlInterface = NULL;
hRet = ::CLSIDFromProgID(L"CAXAInfo.CAPPInfo", &clsid);
if (FAILED(hRet))
return;
hRet = CoCreateInstance(clsid, NULL, CLSCTX_INPROC_SERVER, __uuidof(ICAPPInfo), (void **)&pInterface);
if (FAILED(hRet));
LPDISPATCH lpDisp=NULL;
COleVariant covOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR);
CString CappFileName = L"E:\\30DevSupport\\55CAXA\\ObjectCRX_Samples\\model\\test.CXP";
CString TxtXmlFileName= L"test.txt";
CString filePassword= L"";
CString cardName=L"模壳-工艺过程卡";
CString colName = L"工序内容";
CString sTemp=colName+L"^"+L"HFHZ";
CString sExtFilter = L"txt";
VARIANT_BOOL ret;
BSTR BstrEbFileName,BstrTxtXmlFileName,bstrpassword,bstrColInfo,bstrCardName;
int iCardMask = 1|2|4|8|16;
BstrEbFileName=CappFileName.AllocSysString();
BstrTxtXmlFileName=TxtXmlFileName.AllocSysString();
bstrpassword= filePassword.AllocSysString();
bstrColInfo = sTemp.AllocSysString();
bstrCardName = cardName.AllocSysString();
//hRet = pInterface->raw_GetCappInfoToTxt(BstrEbFileName,BstrTxtXmlFileName,&ret);
BSTR strCommonAtt;
//hRet = pInterface->raw_GetCardCommonAttrib(BstrEbFileName,&strCommonAtt,&ret);
if(sExtFilter == "xml")
{
pXmlInterface =(ICAPPXmlInfo*) pInterface;
BSTR strTemplateSetName;
hRet = pXmlInterface->raw_GetTemplateSetNameForCxpFile(BstrEbFileName,&strTemplateSetName);
hRet=pXmlInterface->raw_InfoToXmlFile(BstrEbFileName,iCardMask,BstrTxtXmlFileName,&ret);
pXmlInterface = NULL;
}
else
{
pXmlInterface =(ICAPPXmlInfo*) pInterface;
BSTR strTemplateSetName;
hRet = pXmlInterface->raw_GetTemplateSetNameForCxpFile(BstrEbFileName,&strTemplateSetName);
//hRet=pXmlInterface->raw_InfoToTxtFile(BstrEbFileName,BstrTxtXmlFileName,&ret);
hRet=pXmlInterface->raw_OpenFile(BstrEbFileName,bstrpassword);
hRet = pXmlInterface->raw_WriteTxtInfoToCard(bstrCardName,bstrColInfo,5,&ret);
hRet=pXmlInterface->raw_CloseFile();
pXmlInterface = NULL;
}
//hRet = pInterface->raw_GetCappInfoToTxt(BstrEbFileName,BstrTxtXmlFileName,&ret);
if(FAILED(hRet))
{
::SysFreeString(BstrEbFileName);
::SysFreeString(BstrTxtXmlFileName);
//HandError(pInterface,IID_ICAPPInfo);
pInterface->Release();
return;
}
::SysFreeString(BstrEbFileName);
::SysFreeString(BstrTxtXmlFileName);
pInterface->Release();
但是调试发现raw_InfoToTxtFile和raw_OpenFile始终返回S_FALSE,同时功能也没有实现。请教一下是怎么回事?不胜感激!
|
|