Export (0) Print
Expand All

Using Macros for Error Handling

Last modified: January 16, 2009

Applies to: Office 2010 | Outlook 2010 | Visual Studio

There are several macros for making it easier to work with HRESULT values.

There are two sets of macros that test for failure or success: HR_SUCCEEDED and HR_FAILED and SUCCEEDED and FAILED. SUCCEEDED is the same as HR_SUCCEEDED and FAILED is the same as HR_FAILED.

In this case, use the ResultFromScode macro to set the HRESULT variable to the corresponding HRESULT value for S_OK.

Commonly used macros are briefly described in the following table.

Macro

Description

MAKE_HRESULT

Constructs an HRESULT from its components.

HR_SUCCEEDED

Tests an HRESULT for a success or warning condition.

HR_FAILED

Tests an HRESULT for an error condition.

HRESULT_CODE

Extracts the error code part of the HRESULT.

HRESULT_FACILITY

Extracts the facility from the HRESULT.

HRESULT_SEVERITY

Extracts the severity bit from the SEVERITY.

SUCCEEDED

Tests an HRESULT for a success or warning condition.

FAILED

Tests an HRESULT for an error condition.

Show:
© 2014 Microsoft