Daily Archives: November 28, 2005

Get Error Message from HRESULT

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; }

Posted in tech | 2 Comments