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

Error Handling Strategies

· 52CE 我爱测

Because interface methods are virtual, it is not possible for a caller to know the full set of values that may be returned from any one call. One implementation of a method may return five values; another may return eight.

Because interface methods are virtual, it is not possible for a caller to know the full set of values that may be returned from any one call. One implementation of a method may return five values; another may return eight.

The documentation lists common values that may be returned for each method; these are the values that you must check for and handle in your code because they have special meanings. Other values may be returned, but because they are not meaningful, you do not need to write special code to handle them. A simple check for zero or nonzero is adequate.

HRESULT Values

The return value of COM functions and methods is an HRESULT. The values of some HRESULTs have been changed in COM to eliminate all duplication and overlapping with the system error codes. Those that duplicate system error codes have been changed to FACILITY_WIN32, and those that overlap remain in FACILITY_NULL. Common HRESULT values and their values are listed in the following table.

HRESULT Value Description
E_ABORT 0x80004004 The operation was aborted because of an unspecified error.
E_ACCESSDENIED 0x80070005 A general access-denied error.
E_FAIL 0x80004005 An unspecified failure has occurred.
E_HANDLE 0x80070006 An invalid handle was used.
E_INVALIDARG 0x80070057 One or more arguments are invalid.
E_NOINTERFACE 0x80004002 The QueryInterface method did not recognize the requested interface. The interface is not supported.
E_NOTIMPL 0x80004001 The method is not implemented.
E_OUTOFMEMORY 0x8007000E The method failed to allocate necessary memory.
E_PENDING 0x8000000A The data necessary to complete the operation is not yet available.
E_POINTER 0x80004003 An invalid pointer was used.
E_UNEXPECTED 0x8000FFFF A catastrophic failure has occurred.
S_FALSE 0x00000001 The method succeeded and returned the boolean value FALSE.
S_OK 0x00000000 The method succeeded. If a boolean return value is expected, the returned value is TRUE.

Network Errors

If the first four digits of the error code are 8007, this indicates a system or network error. You can use the net command to decode these types of errors. To decode the error, first convert the last four digits of the hexadecimal error code to decimal. Then, at the command prompt, type the following, where decimal code is replaced with the return value you want to decode:

net helpmsg <decimal_code>

The net command returns a description of the error. For example, if COM returns the error 8007054B, convert the 054B to decimal (1355). Then type the following:

net helpmsg 1355

The net command returns the error description: "The specified domain did not exist".

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)

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

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