How can I (is there a way to) convert an HRESULT into a system specific error message?

This answer incorporates Raymond Chen's ideas, and correctly discerns the incoming HRESULT, and returns an error string using the correct facility to obtain the error message.

This answer incorporates Raymond Chen's ideas, and correctly discerns the incoming HRESULT, and returns an error string using the correct facility to obtain the error message: ///////////////////////////// // ComException CString FormatMessage(HRESULT result) { CString strMessage; WORD facility = HRESULT_FACILITY(result); CComPtr iei; if (S_OK == GetErrorInfo(0, &iei) && iei) { // get the error description from the IErrorInfo BSTR bstr = NULL; if (SUCCEEDED(iei->GetDescription(&bstr))) { // append the description to our label strMessage. Append(bstr); // done with BSTR, do manual cleanup SysFreeString(bstr); } } else if (facility == FACILITY_ITF) { // interface specific - no standard mapping available strMessage. Append(_T("FACILITY_ITF - This error is interface specific.No further information is available.

")); } else { // attempt to treat as a standard, system error, and ask FormatMessage to explain it CString error; CErrorMessage::FormatMessage(error, m_result); if (!error.IsEmpty()) strMessage. Append(error); } return strMessage; }.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions