The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

_com_error Class


The latest version of this topic can be found at _com_error Class.

Microsoft Specific**

A _com_error object represents an exception condition detected by the error-handling wrapper functions in the header files generated from the type library or by one of the COM support classes. The _com_error class encapsulates the HRESULT error code and any associated IErrorInfo Interface object.


_com_errorConstructs a _com_error object.


operator =Assigns an existing _com_error object to another.

Extractor Functions

ErrorRetrieves the HRESULT passed to the constructor.
ErrorInfoRetrieves the IErrorInfo object passed to the constructor.
WCodeRetrieves the 16-bit error code mapped into the encapsulated HRESULT.

IErrorInfo Functions

DescriptionCalls IErrorInfo::GetDescription function.
HelpContextCalls IErrorInfo::GetHelpContext function.
HelpFileCalls IErrorInfo::GetHelpFile function
SourceCalls IErrorInfo::GetSource function.
GUIDCalls IErrorInfo::GetGUID function.

Format Message Extractor

ErrorMessageRetrieves the string message for HRESULT stored in the _com_error object.

ExepInfo.wCode to HRESULT Mappers

HRESULTToWCodeMaps 32-bit HRESULT to 16-bit wCode.
WCodeToHRESULTMaps 16-bit wCode to 32-bit HRESULT.

Header: comdef.h

Lib: comsuppw.lib or comsuppwd.lib (see /Zc:wchar_t (wchar_t Is Native Type) for more information)

Compiler COM Support Classes
IErrorInfo Interface