?? comdef_vs7.h
字號:
/***
* comdef.h - Native C++ compiler COM support - main definitions header
*
* Copyright (C) 1996-1999 Microsoft Corporation
* All rights reserved.
*
****/
#if !defined(_INC_COMDEF)
#define _INC_COMDEF
#if _MSC_VER > 1000
#pragma once
#endif
#ifndef __cplusplus
#error Native Compiler support only available in C++ compiler
#endif
#include <ole2.h>
#include <olectl.h>
#include <comutil.h>
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable: 4244)
#pragma warning(disable: 4290)
#pragma comment(lib, "comsupp.lib")
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "ole32.lib")
#pragma comment(lib, "oleaut32.lib")
class _com_error;
void __stdcall
_com_raise_error(HRESULT hr, IErrorInfo* perrinfo = 0) throw(_com_error);
void __stdcall
_com_issue_error(HRESULT) throw(_com_error);
void __stdcall
_com_issue_errorex(HRESULT, IUnknown*, REFIID) throw(_com_error);
HRESULT __stdcall
_com_dispatch_propget(IDispatch*, DISPID, VARTYPE, void*) throw(_com_error);
HRESULT __cdecl
_com_dispatch_propput(IDispatch*, DISPID, VARTYPE, ...) throw(_com_error);
HRESULT __cdecl
_com_dispatch_method(IDispatch*, DISPID, WORD, VARTYPE, void*,
const wchar_t*, ...) throw(_com_error);
HRESULT __stdcall
_com_dispatch_raw_propget(IDispatch*, DISPID, VARTYPE, void*) throw();
HRESULT __cdecl
_com_dispatch_raw_propput(IDispatch*, DISPID, VARTYPE, ...) throw();
HRESULT __cdecl
_com_dispatch_raw_method(IDispatch*, DISPID, WORD, VARTYPE, void*,
const wchar_t*, ...) throw();
class _com_error {
public:
// Constructors
//
_com_error(HRESULT hr,
IErrorInfo* perrinfo = NULL,
bool fAddRef = false) throw();
_com_error(const _com_error& that) throw();
// Destructor
//
virtual ~_com_error() throw();
// Assignment operator
//
_com_error& operator=(const _com_error& that) throw();
// Accessors
//
HRESULT Error() const throw();
WORD WCode() const throw();
IErrorInfo * ErrorInfo() const throw();
// IErrorInfo method accessors
//
_bstr_t Description() const throw(_com_error);
DWORD HelpContext() const throw();
_bstr_t HelpFile() const throw(_com_error);
_bstr_t Source() const throw(_com_error);
GUID GUID() const throw();
// FormatMessage accessors
const TCHAR * ErrorMessage() const throw();
// EXCEPINFO.wCode <-> HRESULT mappers
static HRESULT WCodeToHRESULT(WORD wCode) throw();
static WORD HRESULTToWCode(HRESULT hr) throw();
private:
enum {
WCODE_HRESULT_FIRST = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF, 0x200),
WCODE_HRESULT_LAST = MAKE_HRESULT(SEVERITY_ERROR, FACILITY_ITF+1, 0) - 1
};
const HRESULT m_hresult;
IErrorInfo * m_perrinfo;
mutable TCHAR * m_pszMsg;
};
inline _com_error::_com_error(HRESULT hr,
IErrorInfo* perrinfo,
bool fAddRef) throw()
: m_hresult(hr), m_perrinfo(perrinfo), m_pszMsg(NULL)
{
if (m_perrinfo != NULL && fAddRef) {
m_perrinfo->AddRef();
}
}
inline _com_error::_com_error(const _com_error& that) throw()
: m_hresult(that.m_hresult), m_perrinfo(that.m_perrinfo), m_pszMsg(NULL)
{
if (m_perrinfo != NULL) {
m_perrinfo->AddRef();
}
}
inline _com_error::~_com_error() throw()
{
if (m_perrinfo != NULL) {
m_perrinfo->Release();
}
if (m_pszMsg != NULL) {
LocalFree((HLOCAL)m_pszMsg);
}
}
inline _com_error& _com_error::operator=(const _com_error& that) throw()
{
if (this != &that) {
this->_com_error::~_com_error();
this->_com_error::_com_error(that);
}
return *this;
}
inline HRESULT _com_error::Error() const throw()
{
return m_hresult;
}
inline WORD _com_error::WCode() const throw()
{
return HRESULTToWCode(m_hresult);
}
inline IErrorInfo * _com_error::ErrorInfo() const throw()
{
if (m_perrinfo != NULL) {
m_perrinfo->AddRef();
}
return m_perrinfo;
}
inline _bstr_t _com_error::Description() const throw(_com_error)
{
BSTR bstr = NULL;
if (m_perrinfo != NULL) {
m_perrinfo->GetDescription(&bstr);
}
return _bstr_t(bstr, false);
}
inline DWORD _com_error::HelpContext() const throw()
{
DWORD dwHelpContext = 0;
if (m_perrinfo != NULL) {
m_perrinfo->GetHelpContext(&dwHelpContext);
}
return dwHelpContext;
}
inline _bstr_t _com_error::HelpFile() const throw(_com_error)
{
BSTR bstr = NULL;
if (m_perrinfo != NULL) {
m_perrinfo->GetHelpFile(&bstr);
}
return _bstr_t(bstr, false);
}
inline _bstr_t _com_error::Source() const throw(_com_error)
{
BSTR bstr = NULL;
if (m_perrinfo != NULL) {
m_perrinfo->GetSource(&bstr);
}
return _bstr_t(bstr, false);
}
inline _GUID _com_error::GUID() const throw()
{
_GUID guid;
memcpy(&guid, &__uuidof(NULL), sizeof(_GUID));
if (m_perrinfo != NULL) {
m_perrinfo->GetGUID(&guid);
}
return guid;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -