Using Macros for Error Handling
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. |
MAKE_SCODE |
Returns an SCODE given the severity bit, facility code, and error code that comprise the SCODE. |
HRESULT_CODE |
Extracts the error code portion of the HRESULT. |
HRESULT_FACILITY |
Extracts the facility code of the HRESULT. |
HRESULT_SEVERITY |
Extracts the severity bit of the HRESULT. |
SCODE_CODE |
Extracts the error code portion of the SCODE. |
SCODE_FACILITY |
Extracts the facility code of the SCODE. |
SCODE_SEVERITY |
Extracts the severity field of the SCODE. |
SUCCEEDED |
Tests the severity bit of the SCODE or HRESULT; returns TRUE if the severity is zero and FALSE if it is one. |
FAILED |
Tests the severity bit of the SCODE or HRESULT; returns TRUE if the severity is one and FALSE if it is zero. |
IS_ERROR |
Provides a generic test for errors on any status value. |
HRESULT_FROM_WIN32 |
Maps a system error code to an HRESULT value. |
HRESULT_FROM_NT |
Maps an NT status value to an HRESULT value. |
Related topics
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για