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


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

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


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

示例1: HandleComErrorException

//*****************************************************************************
//* Function Name: HandleComErrorException
//*   Description: Handle a _com_error exception. This routine is called from
//*                catch blocks for _com_error exceptions.
//*****************************************************************************
HRESULT HandleComErrorException (
	LPCTSTR				p_lpszFile,
	UINT				p_uLine,
	const _com_error&	p_ce)
{
	(void) HandleFacilityInternetComErrorException (p_ce);

	// Preserve the logical thread's error object. This is cleared when
	// _com_issue_error[ex] calls the Automation ::GetErrorInfo() function.

	// Attach the raw interface pointer returned by _com_error::ErrorInfo()
	// to our smart pointer. _com_error::ErrorInfo() AddRef's the raw
	// interface pointer that it returns. We want to encapsulate this
	// raw interface pointer in a smart pointer without performing an
	// additional AddRef.
	IErrorInfoPtr l_spErrorInfo (p_ce.ErrorInfo (), false /* fAddRef */);

	if (l_spErrorInfo) {
		// There is one reference to the error object in p_ce. There is another
		// reference in l_spErrorInfo. Both of these references will be released
		// by the time we leave the caller's catch block. The COM run-time's
		// reference to the error object will have been cleared when
		// _com_issue_error[ex] was called. By calling SetErrorInfo(),
		// we preserve the logical thread's error object.
		(void) ::SetErrorInfo (0 /* dwReserved */, l_spErrorInfo);
	}

	return p_ce.Error ();
}
开发者ID:taylorjg,项目名称:WineApi_CXX,代码行数:34,代码来源:ComErrorHandling.cpp

示例2: 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

示例3: 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

示例4: ErrorMessage

void CMktStructureBaseDlg::ErrorMessage (const _com_error & e)
{
	StatusMessage ( e.ErrorInfo() ? (LPCTSTR) e.Description() : e.ErrorMessage()  );
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:4,代码来源:MktStructureBaseDlg.cpp


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