📄 stcomerror.h
字号:
#if !defined(AFX_STUTIL_H__C403F6AF_B3FA_4BDA_A15F_7DA68EB6E3BF__INCLUDED_)
#define AFX_STUTIL_H__C403F6AF_B3FA_4BDA_A15F_7DA68EB6E3BF__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
/////////////////////////////////////////////////////////////////////////////
// The CSTComError class encapsulates the HRESULT error code.
class CSTComError
{
public:
// Default constructor creates object that encapsulates S_OK code
CSTComError();
// Default object that encapsulates the given error code
CSTComError(HRESULT hrError);
// Copy constructor.
CSTComError(const CSTComError &src);
// Assignes information about COM error
CSTComError& operator=(const CSTComError &src);
// Raw HRESULT item passed into the constructor.
HRESULT Error() const;
private:
HRESULT m_hrError;
};
// Returns information about the last COM error
CSTComError GetComError();
extern CSTComError lastComError;
/////////////////////////////////////////////////////////////////////////////
// Functions and macros for handling COM error without C++ exceptions (these
// exceptions are not implemented in eVC).
// Code of the exception that will be thrown in case of
// COM error HRESULT.
#define EXCEPTION_COMERROR 4549
// Definition of standard function that is used by smart
// pointers to report about error HRESULT code. This function
// throws exception using RaiseException function. This
// exception could be catched using
// __except (CATCH_COM_ERROR)
// code. If ST_IGNORE_COM_EXCEPTIONS is defined this function
// does nothing (no exception is thrown).
extern void __stdcall _com_issue_error(HRESULT hResult);
// Definition of standard function that is used by smart
// pointers to report about error HRESULT code. This function
// throws exception using RaiseException function. This
// exception could be catched using
// __except (CATCH_COM_ERROR)
// code. If ST_IGNORE_COM_EXCEPTIONS is defined this function
// does nothing (no exception is thrown).
extern void __stdcall _com_issue_errorex(HRESULT hResult, IUnknown* pUnknown, REFIID refid);
// Checks whether the exception corresponds to COM error or
// not and fill lastComError variable with information about
// COM error. This function should be called from __except.
// Returns true is dwCode equals
extern int ComErrorFilterFunction(DWORD dwCode, LPEXCEPTION_POINTERS info);
// This macro represents right calling of ComErrorFilterFunction
// function from __except. Just write
// __except (CATCH_COM_ERROR)
// to catch COM error exceptions.
#define CATCH_COM_ERROR ComErrorFilterFunction(GetExceptionCode(), GetExceptionInformation())
#endif // !defined(AFX_STUTIL_H__C403F6AF_B3FA_4BDA_A15F_7DA68EB6E3BF__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -