本文整理汇总了C++中IPersistStreamInit::QueryInterface方法的典型用法代码示例。如果您正苦于以下问题:C++ IPersistStreamInit::QueryInterface方法的具体用法?C++ IPersistStreamInit::QueryInterface怎么用?C++ IPersistStreamInit::QueryInterface使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPersistStreamInit
的用法示例。
在下文中一共展示了IPersistStreamInit::QueryInterface方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CoCreateInstance
static cgMSXML::IXMLDocument* XML_GetDocument(
CGT_CDiagMsg* pdm,
CG_CIECFront* pFront,
const TCHAR* pszXMLFile,
__int64* pOnOpenLastWriteFileTime
)
{
cgMSXML::IXMLDocument *pDoc = NULL;
IStream *pStm = NULL;
IPersistStreamInit *pPSI = NULL;
HRESULT hr;
// Create an empty XML document.
hr = CoCreateInstance(cgMSXML::CLSID_XMLDocument, NULL, CLSCTX_INPROC_SERVER,
cgMSXML::IID_IXMLDocument, (void**)&pDoc);
if(FAILED(hr) || !pDoc)
goto fatalError;
//try to open the disk or lib file:
if(!LoadFileToIStream(pdm, pFront, pszXMLFile, &pStm, pOnOpenLastWriteFileTime))
return NULL;
assert(pStm);
// Get the IPersistStreamInit interface to the XML doc.
hr = pDoc->QueryInterface(IID_IPersistStreamInit, (void **)&pPSI);
if(FAILED(hr) || !pPSI)
goto fatalError;
// Init the XML doc from the stream.
hr = pPSI->Load(pStm);
if(FAILED(hr))
{
// Print error information !
cgMSXML::IXMLError *pXMLError = NULL ;
cgMSXML::_xml_error xmle;
hr = pPSI->QueryInterface(cgMSXML::IID_IXMLError, (void **)&pXMLError);
if(FAILED(hr) || !pXMLError)
goto fatalError;
hr = pXMLError->GetErrorInfo(&xmle);
if(FAILED(hr))
goto fatalError;
pXMLError->Release();
//different error message formats
//if found string is ??? xmle._pszExpected seem to be a
//preformated message ready to dump
if(!wcscmp(xmle._pszFound, L"???"))
{
pdm->msg3(CG_E_XML_PARSE_ERROR, NULL, pszXMLFile,
pdm->jot1()<<((int)xmle._nLine), pdm->jot2()<<xmle._pszExpected);
}
else
{
pdm->msg3(CG_E_XML_PARSE_ERROR, NULL, pszXMLFile,
pdm->jot1()<<((int)xmle._nLine), pdm->jot2()<<xmle._pszFound);
}
SysFreeString(xmle._pszFound);
SysFreeString(xmle._pszExpected);
SysFreeString(xmle._pchBuf);
pDoc->Release();
pDoc = NULL;
}
// Release any used interfaces.
if(pPSI)
pPSI->Release();
if(pStm)
pStm->Release();
return pDoc;
fatalError:
pdm->sysErr(hr, NULL, _T("CLSID_XMLDocument for file: "), pszXMLFile);
return NULL;
}