Hi all,



Is there a way to convert an HRESULT hex error code to a string? To better illustrate this, here is a sample code:



HRESULT hr = CoInitialize(NULL);

if(FAILED(hr))
{
//This is what I want to store into a string.
//"Failed to Initialize COM. Error code = 0x" << hex << hr << endl;

string hexerrorcode = ?;

CoUninitialize();
return 0;
}

I am not sure how to put it into string.



Can anyone help me with this?



Thank you!