关于DataAbort
做了一个对话框程序,关于初始化的代码就不贴了,只贴关键部分
BOOL CAudioPlayer::WmPlayerInit()
{
AtlAxWinInit();
CComPtr<IAxWinHostWindow> spHost;
CComPtr<IConnectionPointContainer> spConnectionContainer;
CComWMPEventDispatch *pEventListener = NULL;
CComPtr<IWMPEvents> spEventListener;
HRESULT hr;
m_dwAdviseCookie = 0;
// create window
m_wndWMP.Create(m_hWnd, m_rcClient, NULL, WS_CHILD);
if (NULL == m_wndWMP.m_hWnd)
goto FAILURE;
// load OCX in window
hr = m_wndWMP.QueryHost(&spHost);
if (FAILMSG(hr))
goto FAILURE;
hr = spHost->CreateControl(CComBSTR(_T("{6BF52A52-394A-11d3-B153-00C04F79FAA6}")), m_wndWMP, 0);
if (FAILMSG(hr))
goto FAILURE;
hr = m_wndWMP.QueryControl(&m_spWMPPlayer);
if (FAILMSG(hr))
goto FAILURE;
// start listening to events
hr = CComWMPEventDispatch::CreateInstance(&pEventListener);
spEventListener = pEventListener;
if (FAILMSG(hr))
goto FAILURE;
hr = m_spWMPPlayer->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&spConnectionContainer);
if (FAILMSG(hr))
goto FAILURE;
// See if OCX supports the IWMPEvents interface
hr = spConnectionContainer->FindConnectionPoint(__uuidof(IWMPEvents), &m_spConnectionPoint);
if (FAILMSG(hr))
goto FAILURE;
hr = m_spConnectionPoint->Advise(spEventListener, &m_dwAdviseCookie);
if (FAILMSG(hr))
goto FAILURE;
// Hide the Windows Media Player control user interface.
m_spWMPPlayer->put_uiMode(L"invisible");
return 0;
FAILURE:
::PostQuitMessage(0);
return FALSE;
}
void CAudioPlayer::OnDestroy()
{
CDialog::OnDestroy();
// TODO: 在此处添加消息处理程序代码
if (CAudioPlayer::m_spConnectionPoint)
{
if (0 != CAudioPlayer::m_dwAdviseCookie)
CAudioPlayer::m_spConnectionPoint->Unadvise(CAudioPlayer::m_dwAdviseCookie);
CAudioPlayer::m_spConnectionPoint.Release();
}
if (CAudioPlayer::m_spWMPControls)
CAudioPlayer::m_spWMPControls.Release();
if (CAudioPlayer::m_spWMPSettings)
CAudioPlayer::m_spWMPSettings.Release();
if (CAudioPlayer::m_spWMPMedia)
CAudioPlayer::m_spWMPMedia.Release();
if (CAudioPlayer::m_spWMPPlayer)
{
CAudioPlayer::m_spWMPPlayer->close();
CAudioPlayer::m_spWMPPlayer.Release();
}
m_wndWMP.DestroyWindow();
AtlAxWinTerm();
PostQuitMessage(0);
}
播放器可以正常使用,在执行到m_wndWMP.DestroyWindow()的时候会出现一个错误提示:
Data Abort: Thread=9651ecc4 Proc=80097120 'mp3fram.exe'
AKY=00010001 PC=03f7035c(coredll.dll+0x0002235c) RA=03f70490(coredll.dll+0x00022490) BVA=939df958 FSR=00000405
小弟初接触ATL,实在不明白这个错误是怎么产生的,请各位达达不吝赐教。