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; // ActiveX host window class.
CComPtr<IWMPPlayer> m_spWMPPlayer; // Smart pointer to IWMPPlayer interface.
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);
//when I switch to Static Link to ATL from Dynamic Link to ATL, I always get E_FAIL
hr = m_wndView.QueryHost(&spHost);
Anyone can help me?
The error code is entirely function specific. Think of piece of code [on the other side] that does
return E_FAIL;What additional detail one can get from it? Chances are high you have no detail at all.Sometimes you can obtain additional information using
GetErrorInfoAPI which in your case – having your code snippet in mind – is unlikely.The best you can do is to step inside to reach as close as possible to the origin of the code in order to tell where it comes from.