Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. COM
  4. Human Readable HRESULTs

Human Readable HRESULTs

Scheduled Pinned Locked Moved COM
comtutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Phil Harding
    wrote on last edited by
    #1

    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"

    Phil Harding.
    myBlog [^] | mySite [^]

    M R L 3 Replies Last reply
    0
    • P Phil Harding

      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"

      Phil Harding.
      myBlog [^] | mySite [^]

      M Offline
      M Offline
      Mike Dimmick
      wrote on last edited by
      #2

      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 in WinError.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 is FACILITY_ITF) and will have different meanings for different interfaces. I'm not sure if FormatMessage will directly handle error codes in the 0x8007nnnn (FACILITY_WIN32) range, which are mapped from the Win32 error codes below 65536 (using HRESULT_FROM_WIN32).

      Stability. What an interesting concept. -- Chris Maunder

      1 Reply Last reply
      0
      • P Phil Harding

        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"

        Phil Harding.
        myBlog [^] | mySite [^]

        R Offline
        R Offline
        Roger Stoltz
        wrote on last edited by
        #3

        You're not thinking about ::FormatMessage(), are you? It would give you the string "Unspecified error." for the error code E_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

        1 Reply Last reply
        0
        • P Phil Harding

          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"

          Phil Harding.
          myBlog [^] | mySite [^]

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          If you are looking for a tool - HRPlus[^] See if the following blog entry helps http://blogs.msdn.com/ericlippert/archive/2003/10/22/53267.aspx[^]

          S o h a i l K a d i w a l a
          To Err Is Human; to Debug, Divine

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups