Reading HRESULT codes

Although HRESULT codes are so common and structure is simple and well known, and even Visual Studio helps decoding the values nowadays, looking up for code takes some effort: hexadecimal value, searching through SDK headers or online, overlapped regions of codes in FACILITY_ITF etc.

Now is there an answer to the challenge of easy decoding without routinely looking up Windows SDK every time? A helper system tray application makes a nice try. I used to use HR Plus (HR+) application for some time, but at some point even its small bugs started being annoying. Additionally, this one has a priority to decoding DirectShow, Windows Media and Media Foundation error codes.

So having the app started, copy HRESULT or plain system error code such as ERROR_ACCESS_DENIED (5) into clipboard, decimal or hexadecimal, and have it popped up. A click on the balloon googles for code details.

Let us see what is in there. We are using FormatMessage API to look for code message in the following order of preference: DirectShow, Windows Media, Media Foundation, Windows Sockets, WinTHTP, WinInet, System. If the code is found – and this really covers a huge number of codes, there might be additional lookup for the code identifier.