关于DataAbort

seamancode 2009-07-25 02:53:56
做了一个对话框程序,关于初始化的代码就不贴了,只贴关键部分
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,实在不明白这个错误是怎么产生的,请各位达达不吝赐教。
...全文
153 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

3,248

社区成员

发帖
与我相关
我的任务
社区描述
ATL,Active Template Library活动(动态)模板库,是一种微软程序库,支持利用C++语言编写ASP代码以及其它ActiveX程序。
社区管理员
  • ATL/ActiveX/COM社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧