- HRESULT
HRESULT is the
data type used to indicate the status of operations inMicrosoft 's components. An HRESULT value has 32 bits divided into three fields: a severity code, a facility code, and an error code. The severity code indicates whether the return value represents information, warning, or error. The facility code identifies the area of the system responsible for the error. The error code is a unique number that is assigned to represent the exception. Each exception is mapped to a distinct HRESULT. Whenmanaged code throws an exception, theruntime passes the HRESULT to the COM client. When unmanaged code returns an error, the HRESULT is converted to an exception, which is then thrown by the runtime.HRESULTs are 32 bit values laid out as follows:3 3 2 2 2 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 +-+-+-+-+-+---------------------+-------------------------------+
S|R|C|N|r| Facility | Code
+-+-+-+-+-+---------------------+-------------------------------+Details
*S - Severity - indicates success/fail
**0 - Success
**1 - Failure
*R - reserved portion of the facility code, corresponds to NT's second severity bit.
**1 - Severe Failure
*C - Customer - This bit specifies if the value is customer-defined or Microsoft-defined. The bit is set for customer-defined values and clear for Microsoft-defined values
*N - reserved portion of the facility code. Used to indicate a mapped NT status value.
*r - reserved portion of the facility code. Reserved for internal use. Used to indicate HRESULT values that are not status values, but are instead message ids for display strings.
*Facility - is the unreserved portion of facility code
**1 - RPC
**2 - Dispatch
**3 - Storage
**4 - ITF
**5 -
**6 -
**7 -Win32
**8 - Windows
**9 - SSPI
**10 - SCARD
**11 - COMPLUS
**12 - AAF
**13 - URT
**14 - ACS
**15 - DPLAY
**16 - UMI
**17 - SXS
**18 - WINDOWS CE
**19 - HTTP
**20 - BACKGROUNDCOPY
**21 - CONFIGURATION
**22 - STATE MANAGEMENT
**23 - META DIRECTORY
**24 - WINDOWS UPDATE
**25 - DIRECTORY SERVICE
**26 - GRAPHICS
**27 - SHELL
**28 - TPM SERVICES
**29 - TPM SOFTWARE
**30 - PLA
**31 - FVE
**32 - FWP
**33 - WINRM
*Code - is the facility's status codeExamples
*0x80070005
**8 - Failure
**7 - Win32
**5 - "Access Denied"
*0x80090032
**8 - Failure
**9 - SSPI
**32 - "The request is not supported"These values are defined in the corresponding header (.h) files with the Microsoft Windows Platforms SDK or DDK. You can use a tool called [http://www.microsoft.com/downloads/details.aspx?FamilyID=be596899-7bb8-4208-b7fc-09e02a13696c&DisplayLang=en ERR.EXE] to take the value and translate it to the corresponding error string.
External links
* [http://msdn2.microsoft.com/en-us/library/cc231198.aspx Microsoft Open Protocol Specification - HRESULT Values]
* [http://msdn2.microsoft.com/en-us/library/ms526450.aspx Microsoft Developer Network Reference]
* [http://msdn2.microsoft.com/en-us/library/aa383751.aspx#ctl00_LibFrame_ctl112 Windows Data Types]
* [http://msdn2.microsoft.com/en-us/library/ms691242.aspx Using Macros for Error Handling]An opaque result handle defined to be zero for a successful return from a function and nonzero if error or status information is returned. To obtain the "Code" part of an HRESULT, use the HRESULT_CODE() macro.
To check if a call that returns an HRESULT succeeded, make sure the "S" field is 0 (i.e. the number is non-negative) or use the SUCCEEDED() macro.
Wikimedia Foundation. 2010.