In the Microsoft® Windows® operating system, error codes are returned as signed 32-bit HRESULT values that indicate the status of an operation. The high-order sign bit indicates success or failure of the particular method function call.
Interpreting HRESULTs
The HRESULT data type is composed of fields depicted by the following diagram:
.gif)
The 32-bit value is used to describe an error or warning and is composed of a 1-bit code that indicates the severity (S) of the condition; 0 for success and 1 for failure. The severity code is followed by 4 reserved bits depicted as R, C, N, and r, and then by an 11-bit facility code that indicates responsibility for the error or warning that is defined in the method implementation.
The Facility codes and Error codes are defined by the Winerror.h header file. The following table lists some typical HRESULT values:
| Return value/code | Description |
|---|
0x00000000 S_OK |
Operation successful
|
0x80004001 E_NOTIMPL |
Not implemented
|
0x80004002 E_NOINTERFACE |
Interface not supported
|
0x80004004 E_ABORT |
Operation aborted
|
0x80004005 E_FAIL |
Unspecified failure
|
0x80070057 E_INVALIDARG |
One or more arguments are invalid
|
Note Because error codes are implementation specific, two identical HRESULTs that are returned from two different interfaces can have different meanings.