本文整理汇总了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 ();
}
示例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();
}
示例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();
}
}
示例4: ErrorMessage
void CMktStructureBaseDlg::ErrorMessage (const _com_error & e)
{
StatusMessage ( e.ErrorInfo() ? (LPCTSTR) e.Description() : e.ErrorMessage() );
}