Need to look up the error string for an HRESULT code? Here’s some code to do so.
#include <comdef.h>
CString GetMsgForHresult(HRESULT hr)
{
CString cs;
CString msg = _com_error(hr).ErrorMessage();
cs.Format(_T("Error 0x%08x: %s"), hr, msg);
return cs;
}
It looks like
_com_error::ErrorMessage()
usesFormatMessage
internally.Pingback: Generate diagnostic message for HRESULT codes? | The Largest Forum Archive