Human Readable HRESULTs
-
Does anyone know if there is a mechanism by which you can convert/format an HRESULT value (say 0x80004005) to a human readable equivalent (in the case of the example 0x80004005 = "E_FAIL") Obviously I could create a static map of HRESULTS to Message Text, just wondered if there was a pre-existing way to do it?
- "I'm not lying, I'm just writing fiction with my mouth"
-
Does anyone know if there is a mechanism by which you can convert/format an HRESULT value (say 0x80004005) to a human readable equivalent (in the case of the example 0x80004005 = "E_FAIL") Obviously I could create a static map of HRESULTS to Message Text, just wondered if there was a pre-existing way to do it?
- "I'm not lying, I'm just writing fiction with my mouth"
FormatMessage
will convert to the 'user-friendly' error message. It's not that user-friendly, of course, because the message is necessarily generic. The English message text is given inWinError.h
, in a comment above the definition of the message constant. Be aware that errors with codes 0x8004nnnn are relative to the COM interface you used (4 isFACILITY_ITF
) and will have different meanings for different interfaces. I'm not sure ifFormatMessage
will directly handle error codes in the 0x8007nnnn (FACILITY_WIN32
) range, which are mapped from the Win32 error codes below 65536 (usingHRESULT_FROM_WIN32
).Stability. What an interesting concept. -- Chris Maunder
-
Does anyone know if there is a mechanism by which you can convert/format an HRESULT value (say 0x80004005) to a human readable equivalent (in the case of the example 0x80004005 = "E_FAIL") Obviously I could create a static map of HRESULTS to Message Text, just wondered if there was a pre-existing way to do it?
- "I'm not lying, I'm just writing fiction with my mouth"
You're not thinking about
::FormatMessage()
, are you? It would give you the string "Unspecified error." for the error codeE_FAIL
. But you want the string "E_FAIL", right? If your answer is 'yes' I don't think there exist such a mapping between a C++ identifier and a string. At least not any I know. But it does however make me question if the string should be considered "human readable"...:~ If I really needed that I would parse <winerror.h>.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown -
Does anyone know if there is a mechanism by which you can convert/format an HRESULT value (say 0x80004005) to a human readable equivalent (in the case of the example 0x80004005 = "E_FAIL") Obviously I could create a static map of HRESULTS to Message Text, just wondered if there was a pre-existing way to do it?
- "I'm not lying, I'm just writing fiction with my mouth"