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


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

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


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

示例1: GetModuleName

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

示例2: RecordErrorMsg

void CDBAdo::RecordErrorMsg(_com_error comError)
{
	_bstr_t	bstrDescribe(comError.Description());

	m_strErrorMsg.Format(TEXT("ADO 错误:0x%8x,%s"), comError.Error(), (LPCTSTR)bstrDescribe);
}
开发者ID:HanoiGuo,项目名称:BoJay-SFIS,代码行数:6,代码来源:DBAdo.cpp

示例3: PrintErrorInfo

void PrintErrorInfo(_com_error e)
{
	wprintf(L"错误源:%s\n", (wchar_t*)e.Source());
	wprintf(L"错误信息:%s;HResult:0x%x\n", e.ErrorMessage(), e.Error());
	wprintf(L"错误描述:%s\n", (wchar_t*)e.Description());
}
开发者ID:zhaohengyi,项目名称:dotNet_PInvoke,代码行数:6,代码来源:TestException.cpp

示例4: show_error

void show_error(_com_error &e)
{
    printf("(0x%08X)\n\r",e.Error());
    PrintLine("");
    printf("%s\n\r",(char*)e.Description());
}
开发者ID:Faham,项目名称:emophiz,代码行数:6,代码来源:42_Reading_VARIANT_Data_MFC.cpp

示例5: ErrorMessage

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

示例6: HandleFacilityInternetComErrorException

//*****************************************************************************
//* Function Name: HandleFacilityInternetComErrorException
//*   Description: Special handling for errors with a facility of
//*                FACILITY_INTERNET.
//*****************************************************************************
static bool HandleFacilityInternetComErrorException (const _com_error&	p_ce)

{
	bool l_bHandled = false;

	// In nearly all cases that I have observed so far,
	// when the failure HRESULT has a facility of FACILITY_INTERNET,
	// the Description/ErrorMessage is just a generic string
	// containing the error code rather than a meaningful description.
	// However, the corresponding description is often available in the
	// MESSAGETABLE resource of one of the system DLLs associated with
	// internet functionality. Therefore, try to look up the error code
	// in these system DLLs. If the lookup is successful then set new rich
	// error information. In addition, we set the Source and GUID properties
	// of the rich error information according to the active COM method's
	// CLSID and IID.

	try {
		// We are only interested in FACILITY_INTERNET.
		if (HRESULT_FACILITY (p_ce.Error ()) != FACILITY_INTERNET) {
			return false;
		}

		_bstr_t l_sbstrDescription = p_ce.Description ();

		// We are not interested if we already have non-empty rich error
		// information descriptive text.
		if (l_sbstrDescription.length () > 0) {
			return false;
		}

		LPCTSTR l_lpszErrorMessage = p_ce.ErrorMessage();

		// We are not interested unless the system error message begins
		// with "Unknown error".
		if (l_lpszErrorMessage != NULL) {
			static const TCHAR UNKNOWN_ERROR[] = _T("Unknown error");
			if (_tcsnicmp (l_lpszErrorMessage, UNKNOWN_ERROR, _tcslen (UNKNOWN_ERROR)) != 0) {
				return false;
			}
		}

		// If we get to here, then there is no description and no error message.
		// Let's try to lookup the error code in the MESSAGETABLE resources of
		// a few system DLLs in order to try to find a decent error message.

		static LPCTSTR s_rglpszDLLs[] = {
			_T("urlmon.dll"),
			_T("wininet.dll"),
			_T("winhttp.dll"),
			_T("msxml3r.dll")
		};
		static UINT s_uNumDLLs = sizeof (s_rglpszDLLs) / sizeof (*s_rglpszDLLs);

		bool l_bFound = false;
		TCHAR l_szDescription[256] = {0};

		l_bFound =  LookupErrorCode (	p_ce.Error (),
										s_rglpszDLLs,
										s_uNumDLLs,
										l_szDescription,
										256);

		if (!l_bFound) {

			l_bFound =  LookupErrorCode (	HRESULT_CODE (p_ce.Error ()),
											s_rglpszDLLs,
											s_uNumDLLs,
											l_szDescription,
											256);
		}

		if (l_bFound) {

			CLSID	l_clsid = GUID_NULL;
			IID		l_iid   = GUID_NULL;

			CActiveMethodGUIDs::Get (l_clsid, l_iid);

			USES_CONVERSION;
			HRESULT l_hr;

			// Create and populate a standard error object.
			ICreateErrorInfoPtr l_spCreateErrorInfo;
			l_hr = ::CreateErrorInfo (&l_spCreateErrorInfo);
			if (FAILED (l_hr)) _com_issue_error (l_hr);

			// Set the Description property.
			l_hr = l_spCreateErrorInfo->SetDescription (T2OLE (l_szDescription));
			if (FAILED (l_hr)) _com_issue_error (l_hr);

			// Get the ProgID corresponding to rclsid.
			LPOLESTR l_lpoleszProgID = NULL;
			l_hr = ::ProgIDFromCLSID (l_clsid, &l_lpoleszProgID);
			if (FAILED (l_hr)) _com_issue_error (l_hr);
//.........这里部分代码省略.........
开发者ID:taylorjg,项目名称:WineApi_CXX,代码行数:101,代码来源:ComErrorHandling.cpp


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