⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stcomerror.cpp

📁 windows ce开发技巧与实例光盘代码
💻 CPP
字号:
#include "stdafx.h"
#include "STComError.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif



//////////////////////////////////////////////////////////////////////
// CSTComError
//////////////////////////////////////////////////////////////////////

CSTComError::CSTComError() 
	: m_hrError(S_OK)
{
}

CSTComError::CSTComError(HRESULT hrError) 
	: m_hrError(hrError)
{
}

CSTComError::CSTComError(const CSTComError &src) 
	: m_hrError(src.m_hrError)
{
}

CSTComError& CSTComError::operator=(const CSTComError &src)
{
	m_hrError = src.m_hrError;
	return *this;
}

HRESULT CSTComError::Error() const
{
	return m_hrError;
}

CSTComError lastComError;

CSTComError GetComError()
{
	return lastComError;
}


//////////////////////////////////////////////////////////////////////
// COM error handlers
//////////////////////////////////////////////////////////////////////

void __stdcall _com_issue_error(HRESULT hResult)
{
#ifndef ST_IGNORE_COM_EXCEPTIONS
	DWORD *data = new DWORD[1];
	data[0] = hResult;
	RaiseException(EXCEPTION_COMERROR, 0, 1, data);
#endif /*ST_IGNORE_COM_EXCEPTIONS*/
}

void __stdcall _com_issue_errorex(HRESULT hResult, IUnknown* pUnknown, REFIID refid)
{
#ifndef ST_IGNORE_COM_EXCEPTIONS
	DWORD *data = new DWORD[1];
	data[0] = hResult;
	RaiseException(EXCEPTION_COMERROR, 0, 1, data);
#endif /*ST_IGNORE_COM_EXCEPTIONS*/
}

int ComErrorFilterFunction(DWORD dwCode, LPEXCEPTION_POINTERS info)
{
	HRESULT hrResult = info->ExceptionRecord->ExceptionInformation[0];
	lastComError = CSTComError(hrResult);
	return (dwCode==EXCEPTION_COMERROR);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -