Esempio n. 1
0
//-------------------------------------------------------------------------
// Function Name    :GetLastError
// Parameter(s)     :void
// Return           :CString
// Memo             :获取最后的出错信息
//-------------------------------------------------------------------------
CString CXml::GetLastError(void)
{
	ASSERT( m_pDoc != NULL );

	HRESULT hr = S_OK;
	MSXML2::IXMLDOMParseErrorPtr pIParseError = NULL;

	hr = m_pDoc->get_parseError(&pIParseError);
	ASSERT( SUCCEEDED(hr) );

	CString strRet;
	if( pIParseError != NULL )
	{
		LONG value;
		BSTR bstr = NULL;
		hr = pIParseError->get_errorCode(&value);
		ASSERT( SUCCEEDED(hr) );

        hr = pIParseError->get_reason(&bstr);
		ASSERT( SUCCEEDED(hr) );

		strRet = (LPCTSTR)_bstr_t( bstr, true);

		if( bstr != NULL )
		{
			SysFreeString(bstr);
			bstr = NULL;
		}	

		SAFE_RELEASE(pIParseError);		
	}

	return strRet;
}
Esempio n. 2
0
//-------------------------------------------------------------------------
// Function Name    :GetLastError
// Parameter(s)     :void
// Return           :CString
// Memo             :获取最后的出错信息
//-------------------------------------------------------------------------
CString CXml::GetLastError(void) const
{
	ASSERT(m_pDoc != NULL);

	HRESULT hr = S_OK;
	MSXML2::IXMLDOMParseErrorPtr pIParseError = NULL;

	hr = m_pDoc->get_parseError(&pIParseError);
	ASSERT(SUCCEEDED(hr));

	CString strRet;
	if(pIParseError != NULL)
	{
		BSTR bstr = NULL;
        hr = pIParseError->get_reason(&bstr);
		ASSERT(SUCCEEDED(hr));

		strRet = (LPCTSTR)_bstr_t(bstr, false);

		RELEASE_PTR(pIParseError);		
	}

	return strRet;
}