|
When I use ATL in MFC Application(Don't ask me why, just because I like), sometimes I got the error code: E_FAIL. However, it's almost useless for me to locate the specific reason.
I have googled so many times, but found nothing related. I thought there should be something like try{} catch{} in ATL.
Here's some sample code:
CAxWindow m_wndView; CComPtr<IWMPPlayer> m_spWMPPlayer;
AtlAxWinInit();
CComPtr<IAxWinHostWindow> spHost;
HRESULT hr;
CRect rcClient;
GetClientRect(&rcClient);
m_wndView.Create(m_hWnd, rcClient, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
hr = m_wndView.QueryHost(&spHost);
|
|
|
|
|
Use the _com_error class.
Construct an object of this class by passing in the HRESULT value and then use its WCode or ErrorMessage methods to get the error code mapped to the HRESULT value.
|
|
|
|
|
Thank you for your reply.
I have did as what you said, but I only get the error message:
Unspecified error.
Here is my code:
_com_error err(hr);
auto d = err.WCode();
auto s = err.Description();
auto msg = err.ErrorMessage();
|
|
|
|
|
'Unspecified error' is the english error message for E_FAIL . There is no more information available.
|
|
|
|
|
You can try with GetLastError and see if you can get better description of the error . The number returned from the function you can check in msdn.
Good luck
|
|
|
|