当前位置: 首页>>代码示例>>C++>>正文


C++ _com_error::Error方法代码示例

本文整理汇总了C++中_com_error::Error方法的典型用法代码示例。如果您正苦于以下问题:C++ _com_error::Error方法的具体用法?C++ _com_error::Error怎么用?C++ _com_error::Error使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_com_error的用法示例。


在下文中一共展示了_com_error::Error方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dump_com_error

void dump_com_error(_com_error &e)
{
        printf("Error\n");
        printf("\a\tCode = %08lx\n", e.Error());
        printf("\a\tCode meaning = %s", e.ErrorMessage());
        _bstr_t bstrSource(e.Source());
        _bstr_t bstrDescription(e.Description());
        printf("\a\tSource = %s\n", (LPCSTR) bstrSource);
        printf("\a\tDescription = %s\n", (LPCSTR) bstrDescription);
}
开发者ID:mlange,项目名称:dev,代码行数:10,代码来源:main.c

示例2: dump_com_error

void dump_com_error(_com_error &e)
{
    _tprintf(_T("Oops - hit an error!\n"));
    _tprintf(_T("\a\tCode = %08lx\n"), e.Error());
    _tprintf(_T("\a\tCode meaning = %s\n"), e.ErrorMessage());
    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());
    _tprintf(_T("\a\tSource = %s\n"), (LPCTSTR) bstrSource);
    _tprintf(_T("\a\tDescription = %s\n"), (LPCTSTR) bstrDescription);
}
开发者ID:Jinjiego,项目名称:VCSamples,代码行数:10,代码来源:commail.cpp

示例3: HandleErrors

//=--------------------------------------------------------------------------=
// CImp_DrawDlg::HandleErrors
//=--------------------------------------------------------------------------=
// Purpose: This function pops up an error dialog box and aborts further execution.
//  
//
// Parameters:
//    _com_error
//
// Output:
//    none
//
// Notes:
//    This function demonstrates how to pull an HRESULT from the _com_error class.
//
void CImp_DrawDlg::HandleErrors(_com_error &comerr)
{
	HRESULT hr = comerr.Error();
	char szErr[30] = "";
	_itoa_s(hr, szErr, sizeof(szErr), 16);
	CString tempString = "The method returned the error code 0x";
	tempString += szErr;
	tempString += ".  Exiting.";
	MessageBox(tempString, NULL, MB_ICONSTOP | MB_OK);
	AfxAbort();
};
开发者ID:AbdoSalem95,项目名称:WindowsSDK7-Samples,代码行数:26,代码来源:Imp_Dlg.Cpp

示例4: dump_com_error

void dump_com_error(_com_error &e)
{ 
	CString strError;

	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());
	// Print Com errors. 
	strError.Format(_T("Database Engine Error\n\nCode  %08lx\nmean:%s\nSource: %s\nDescription: %s\n"),
		e.Error(), e.ErrorMessage(), (LPTSTR) bstrSource, (LPTSTR) bstrDescription);
	AfxMessageBox(strError,MB_OK+MB_ICONERROR); 
}
开发者ID:eseawind,项目名称:CoalQualityTestSystem,代码行数:11,代码来源:StdAfx.cpp

示例5: PrintComError

void PrintComError(_com_error &e)
{
	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());

	// Print COM errors. 
	PTRACE(1, "catch _com_error:\tError = " << e.Error()
		<< "\tErrorMessage = " << (const char*)e.ErrorMessage()
		<< "\tSource = " << (const char*)bstrSource
		<< "\tDescription = " << (const char*)bstrDescription
		);
}
开发者ID:princetoad,项目名称:callback,代码行数:12,代码来源:database.cpp

示例6: ErrCom

// ErrCom Function
void ErrCom(_com_error &e)
{
	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());
	
	// Print Com errors.  
	printf("Error\n");
	printf("\tCode = %08lx\n", e.Error());
	printf("\tCode meaning = %s\n", e.ErrorMessage());
	printf("\tSource = %s\n", (LPCSTR) bstrSource);
	printf("\tDescription = %s\n", (LPCSTR) bstrDescription);
}
开发者ID:GALICSOFT,项目名称:glc220_src,代码行数:13,代码来源:LnNetOledb.cpp

示例7: ComCatch

/**
 * Used in the catch block for a catched _com_error exception to
 * set the error information object with ::SetErrorInfo and returning
 * the HRESULT error code the corresponds with the exception.
 * If the exception _com_error object holds a error information object
 * exposing the interface IErrorInfo, ::SetErrorInfo with that object
 * will be called.
 * @param   _com_error exceptional object.
 * @return  error code associated with the _com_error object.
 * @exception       -
 * @see ::SetErrorInfo.
*/
HRESULT ComCatch(_com_error & err)
//catches thrown _com_error and sets error info for interface method
//call if available
{
    IErrorInfo* pei;
    pei = err.ErrorInfo();
    if(pei) {
        ::SetErrorInfo(0,pei);
        //do not release it, that is the task of the _com_error class
    }

    return err.Error();
}
开发者ID:LM25TTD,项目名称:ATCMcontrol_Engineering,代码行数:25,代码来源:dlext.cpp

示例8: dump_com_error

//打印调用ADO控件时产生的详细错误信息
void LoadManage::dump_com_error(_com_error &e)
{
	CString ErrorStr;
	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());
	ErrorStr.Format( "/n/tADO Error/n/tCode = %08lx/n/tCode meaning = %s/n/tSource = %s/n/tDescription = %s/n/n",
		e.Error(), e.ErrorMessage(), (LPCTSTR)bstrSource, (LPCTSTR)bstrDescription );
	//在调试窗口中打印错误信息,在Release版中可用DBGView查看错误信息
	::OutputDebugString((LPCTSTR)ErrorStr);
#ifdef _DEBUG
	AfxMessageBox(ErrorStr, MB_OK | MB_ICONERROR);
#endif	
}
开发者ID:Strongc,项目名称:Mobis,代码行数:14,代码来源:LoadManage.cpp

示例9: HandleComErrorException

//*****************************************************************************
//* Function Name: HandleComErrorException
//*   Description: Most of the unit tests use a try/catch block where we catch
//*                _com_error exceptions. This helper function contains common
//*                code for handling these exceptions. We essentially just call
//*                CPPUNIT_FAIL. However, we also include details of the
//*                _com_error exception - specifically, the HRESULT plus either
//*                the rich error information via Description() or the
//*                looked-up error message for the HRESULT via ErrorMessage().
//*****************************************************************************
void HandleComErrorException (const _com_error& p_ce)
{
	try {
		CString l_strMessage;

		_bstr_t l_sbstrDescription = p_ce.Description ();
		if (l_sbstrDescription.length () > 0) {
			l_strMessage.Format (
				_T("Caught _com_error exception with HRESULT 0x%08X; Description: %s"),
				p_ce.Error (),
				static_cast<LPCTSTR>(l_sbstrDescription));
		}
		else {
			LPCTSTR l_lpszErrorMessage = p_ce.ErrorMessage ();
			if (l_lpszErrorMessage != NULL) {
				l_strMessage.Format (
					_T("Caught _com_error exception with HRESULT 0x%08X; ErrorMessage: %s"),
					p_ce.Error (),
					l_lpszErrorMessage);
			}
			else {
				l_strMessage.Format (
					_T("Caught _com_error exception with HRESULT 0x%08X"),
					p_ce.Error ());
			}
		}

		CPPUNIT_FAIL (static_cast<LPCTSTR>(l_strMessage));
	}
	catch (const _com_error& l_ce) {
		CString l_strMessage;
		l_strMessage.Format (
			_T("HandleComErrorException - caught _com_error exception (0x%08X) - original HRESULT was 0x%08X"),
			l_ce.Error (),
			p_ce.Error ());
		CPPUNIT_FAIL (static_cast<LPCTSTR>(l_strMessage));
	}
}
开发者ID:taylorjg,项目名称:WineApi_CXX,代码行数:48,代码来源:Utils.cpp

示例10: TRACE_ComError

void AFX_CDECL CXTPReportDataManager::TRACE_ComError(_com_error &e)
{
    LPCWSTR bstrSource(e.Source());

    // Print COM errors.
    TRACE(_T("COM_ERROR: HRESULT = %08lx, Code meaning = %s, Source = %ls\n"),
          e.Error(), (LPCTSTR)e.ErrorMessage(), (LPCWSTR)bstrSource);
    // Save last COM error.
    XTP_REPORTDATAMANAGER_COM_ERROR* pError = NULL;
    if (m_LastComError.GetSize() >= XTP_REPORTDATAMANAGER_MAX_LAST_COM_ERRORS)
    {
        pError = m_LastComError.GetAt(m_LastComError.GetSize() - 1);
        m_LastComError.RemoveAt(m_LastComError.GetSize() - 1);
    }
    if (!pError)
        pError = new XTP_REPORTDATAMANAGER_COM_ERROR;
    if (!pError)
        return;
    pError->hResult = e.Error();
    pError->strMessage = e.ErrorMessage();
    pError->strSource.Format(_T("%ls"), (LPCWSTR)bstrSource);
    m_LastComError.Add(pError);
}
开发者ID:killbug2004,项目名称:ghost2013,代码行数:23,代码来源:XTPReportDataManager.cpp

示例11: GetComErrorDesc

CString GetComErrorDesc(_com_error e)
{
	HRESULT code = e.Error();
	if(code == TYPE_CAST_ERROR)
		return _T("[VARIANT CAST] type doesn't match");
	else
	{
		IErrorInfo* pei = e.ErrorInfo();
		if(pei)
			return (LPCTSTR)e.Description();
		else
			return e.ErrorMessage();
	}
}
开发者ID:zhangtianshan,项目名称:vc-common-src,代码行数:14,代码来源:VarConv.cpp

示例12: DisplayCOMError

void CUtil::DisplayCOMError(_com_error e)
{
  tstring strError;

  _bstr_t bstrSource(e.Source());
  _bstr_t bstrDescription(e.Description());

  CStringUtil::Format(_T("\a Code : %08lx\n\a Code meaning : %s\n  \
                         \a Source : %s\n\a Description : %s\n"), 
                         e.Error(),
                         e.ErrorMessage(),
                         (LPCTSTR) bstrSource,
                         (LPCTSTR) bstrDescription);

  MessageBox(NULL, strError.c_str(), _T(""), MB_ICONERROR);
}
开发者ID:envi,项目名称:imagepitcher,代码行数:16,代码来源:util.cpp

示例13: dump_com_error

void dump_com_error(_com_error &e)
{
	_bstr_t bstrSource(e.Source());
	_bstr_t bstrDescription(e.Description());
	TCHAR szTemp[1024];
	CString csMsg = "Oops - hit an error!\n";
	wsprintf(szTemp, _T("Code = %08lx\n"), e.Error());
	csMsg += szTemp;
	wsprintf(szTemp, _T("Code meaning = %s\n"), e.ErrorMessage());
	csMsg += szTemp;
	wsprintf(szTemp, _T("Source = %s\n"), bstrSource.length() ? (LPCTSTR)bstrSource : _T("null"));
	csMsg += szTemp;
	wsprintf(szTemp, _T("Description = %s\n"), bstrDescription.length() ? (LPCTSTR)bstrDescription : _T("null"));
	csMsg += szTemp;
	AfxMessageBox(csMsg);
}
开发者ID:jetlive,项目名称:skiaming,代码行数:16,代码来源:stdafx.cpp

示例14: GetModuleName

void Workshare::Logging::LogErrorResult(LPCTSTR fileName, int lineNumber, LPCTSTR function, const _com_error& comError)
{
	try
	{
		if(ShouldLogError())
		{
			CString outputMessage;
			outputMessage.Format(_T("Com Exception:\r\nDetails: 0x%08x - %s"), comError.Error(), (LPCTSTR)comError.Description());
	
			Logger::GetInstance().LogError(fileName, lineNumber, function, outputMessage, ::GetCurrentThreadId(), GetModuleName());
		}
	}
	catch(...)
	{
		::OutputDebugString(L"Error: failed to create ERROR log message for _com_error.");
	}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:17,代码来源:Logging.cpp

示例15: COMERRORMSG

void CAdo::COMERRORMSG(_com_error &e)
{

	CString sMsg, errMsg;
    /////////////////////////////////////////////////////////////////////////
    // Com errors.
    _bstr_t bstrSource(e.Source());
    _bstr_t bstrDescription(e.Description());
    errMsg.Format("%08lx : %s\n", e.Error(), e.ErrorMessage());
    sMsg += errMsg;
    errMsg.Format("Source = %s\n", (LPCSTR) bstrSource);
    sMsg += errMsg;
    errMsg.Format("Description = %s", (LPCSTR) bstrDescription);
    sMsg += errMsg;
    AfxMessageBox(sMsg, MB_ICONSTOP);


}
开发者ID:kevintank,项目名称:e_wiz,代码行数:18,代码来源:Ado.cpp


注:本文中的_com_error::Error方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。