Hade du nytta av den här sidan?
Din feedback om det här innehållet är viktig. Berätta vad du tycker.
Ytterligare feedback?
1500 tecken kvar
Using Macros for Error Handling
EN
Det här innehållet finns inte tillgängligt på ditt språk men här finns den engelska versionen,

Using Macros for Error Handling

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

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.

Visa:
© 2015 Microsoft