大网数据广告活动
Windows 系统接口

Using Macros for Error Handling

· 52CE 我爱测

COM defines a number of macros that make it easier to work with HRESULT values.

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

Error Handling in COM

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.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。