Is there a way to get the string representation of HRESULT value using win API?

Viewed 65402

Is there a function in win API which can be used to extract the string representation of HRESULT value?

The problem is that not all return values are documented in MSDN, for example ExecuteInDefaultAppDomain() function is not documented to return "0x80070002 - The system cannot find the file specified.", however, it does! Therefore, I was wondering whether there is a function to be used in common case.

4 Answers

Since c++11, this functionality is built into the standard library:

#include <system_error>

std::string message = std::system_category().message(hr)
Related