COM defines a number of macros that make it easier to work with HRESULT values.
The error handling macros are described in the following table.
| Macro | Description |
|---|---|
| MAKE_HRESULT | Returns an HRESULT given the severity bit, facility code, and error code that comprise the HRESULT. Note: Calling MAKE_HRESULT for S_OK verification carries a performance penalty. You should not routinely use MAKE_HRESULT for successful results. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-make_scode">MAKE_SCODE</a> | Returns an SCODE given the severity bit, facility code, and error code that comprise the SCODE. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-hresult_code">HRESULT_CODE</a> | Extracts the error code portion of the HRESULT. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-hresult_facility">HRESULT_FACILITY</a> | Extracts the facility code of the HRESULT. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-hresult_severity">HRESULT_SEVERITY</a> | Extracts the severity bit of the HRESULT. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-scode_code">SCODE_CODE</a> | Extracts the error code portion of the SCODE. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-scode_facility">SCODE_FACILITY</a> | Extracts the facility code of the SCODE. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-scode_severity">SCODE_SEVERITY</a> | Extracts the severity field of the SCODE. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-succeeded">SUCCEEDED</a> | Tests the severity bit of the SCODE or HRESULT; returns TRUE if the severity is zero and FALSE if it is one. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-failed">FAILED</a> | Tests the severity bit of the SCODE or HRESULT; returns TRUE if the severity is one and FALSE if it is zero. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-is_error">IS_ERROR</a> | Provides a generic test for errors on any status value. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-hresult_from_win32">HRESULT_FROM_WIN32</a> | Maps a <a href="/windows/desktop/Debug/system-error-codes">system error code</a> to an HRESULT value. |
| <a href="/windows/desktop/api/Winerror/nf-winerror-hresult_from_nt">HRESULT_FROM_NT</a> | Maps an NT status value to an HRESULT value. |
Related topics
Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
