求救:我在CMainFrame::OnAppExit()中,调用CFrameWnd::OnClose(),应用程序退不出来,调用::PostQuitMessage(0),也不行,在Debug版本下,程序会出错,提示是:arning: calling DestroyWindow in CWnd::~CWnd; OnDestroy or PostNcDestroy in derived class will not be called.
继续运行,在Call Stack中 会出现:_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::_Release() line 662 + 15 bytes
_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::~_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >() line 262
$E534() + 34 bytes
doexit(int 0, int 0, int 0) line 353
exit(int 0) line 279 + 13 bytes
WinMainCRTStartup() line 345
KERNEL32! 77e8893d()
好象是Ado的_ConnectionPtr没有关闭,而我确实调用了关闭该连接。
我的OnAppExit程序如下:
void CMainFrame::OnAppExit()
{
// TODO: Add your command handler code here
if(g_Started)
{
//AfxMessageBox("请先结束测试,再关闭系统!");
CMsgDlg dlg;
dlg.m_strMsg = "请先结束测试,再关闭系统!";
dlg.DoModal();
return;
}
CMsgDlg dlg;
dlg.m_strMsg = "你真的要退出本系统么?";
dlg.m_bCancelShow = true;
if(dlg.DoModal() == IDCANCEL)
return;
/////////////////////////////
SysLog(CString("关闭软件"));
#if _DEBUG
try
{
m_FileDataOver.Close();
}
catch(...){}
#endif
//
::Shell_NotifyIcon(NIM_DELETE,&m_tnid);
if(m_pMenu)
{
m_pMenu->Detach();
delete m_pMenu;
}
//
////////////////////////////////
POSITION pos;
pos = this->m_EquipInfoMap.GetStartPosition();
for(pos; pos != NULL; )
{
CString strAddr;
CEquipInfo *pPara = NULL;
m_EquipInfoMap.GetNextAssoc(pos,strAddr,(void *&)pPara);
if(pPara)
delete pPara;
m_EquipInfoMap.RemoveKey(strAddr);
}
m_EquipInfoMap.RemoveAll();
//
CThrRecord *pThrRecord = NULL;
int count = this->m_OutThrList.GetCount();
for(int j = 0; j < count; j++)
{
pThrRecord = NULL;
pThrRecord = (CThrRecord *)this->m_OutThrList.RemoveHead();
if(pThrRecord)
delete pThrRecord;
}
//
if(m_pEquipErrListDlg)
{
//m_pEquipErrListDlg->PostNcDestroy();
//m_pEquipErrListDlg->DestroyWindow();
delete m_pEquipErrListDlg;
}
//////////////////////////////////////////
// unregister CrystalCtrl
//this->UnRegCrystalCtrl();
//
this->m_wndTree.DeleteAllItemsEx();
this->m_wndCirTree.DeleteAllItemsEx(); ///////////////////////////////////////////////
try
{
g_ConnectPtr->Close();
g_Conn->Close();
::CoUninitialize();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
TRACE("Exception thrown for classes generated by #import");
TRACE("\tCode=%081x\n",e.Error());
TRACE("\tCode meaning=%s\n",e.ErrorMessage());
TRACE("\tSource=%s\n",(LPCTSTR)bstrSource);
TRACE("\tDescription=%s\n",(LPCTSTR)bstrDescription);
}
DWORD dwError = ::GetLastError();
CFrameWnd::OnClose();
dwError = ::GetLastError();
//::PostQuitMessage(0);
}
继续运行,在Call Stack中 会出现:_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::_Release() line 662 + 15 bytes
_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >::~_com_ptr_t<_com_IIID<_Connection,&_GUID_00000550_0000_0010_8000_00aa006d2ea4> >() line 262
$E534() + 34 bytes
doexit(int 0, int 0, int 0) line 353
exit(int 0) line 279 + 13 bytes
WinMainCRTStartup() line 345
KERNEL32! 77e8893d()
好象是Ado的_ConnectionPtr没有关闭,而我确实调用了关闭该连接。
我的OnAppExit程序如下:
void CMainFrame::OnAppExit()
{
// TODO: Add your command handler code here
if(g_Started)
{
//AfxMessageBox("请先结束测试,再关闭系统!");
CMsgDlg dlg;
dlg.m_strMsg = "请先结束测试,再关闭系统!";
dlg.DoModal();
return;
}
CMsgDlg dlg;
dlg.m_strMsg = "你真的要退出本系统么?";
dlg.m_bCancelShow = true;
if(dlg.DoModal() == IDCANCEL)
return;
/////////////////////////////
SysLog(CString("关闭软件"));
#if _DEBUG
try
{
m_FileDataOver.Close();
}
catch(...){}
#endif
//
::Shell_NotifyIcon(NIM_DELETE,&m_tnid);
if(m_pMenu)
{
m_pMenu->Detach();
delete m_pMenu;
}
//
////////////////////////////////
POSITION pos;
pos = this->m_EquipInfoMap.GetStartPosition();
for(pos; pos != NULL; )
{
CString strAddr;
CEquipInfo *pPara = NULL;
m_EquipInfoMap.GetNextAssoc(pos,strAddr,(void *&)pPara);
if(pPara)
delete pPara;
m_EquipInfoMap.RemoveKey(strAddr);
}
m_EquipInfoMap.RemoveAll();
//
CThrRecord *pThrRecord = NULL;
int count = this->m_OutThrList.GetCount();
for(int j = 0; j < count; j++)
{
pThrRecord = NULL;
pThrRecord = (CThrRecord *)this->m_OutThrList.RemoveHead();
if(pThrRecord)
delete pThrRecord;
}
//
if(m_pEquipErrListDlg)
{
//m_pEquipErrListDlg->PostNcDestroy();
//m_pEquipErrListDlg->DestroyWindow();
delete m_pEquipErrListDlg;
}
//////////////////////////////////////////
// unregister CrystalCtrl
//this->UnRegCrystalCtrl();
//
this->m_wndTree.DeleteAllItemsEx();
this->m_wndCirTree.DeleteAllItemsEx(); ///////////////////////////////////////////////
try
{
g_ConnectPtr->Close();
g_Conn->Close();
::CoUninitialize();
}
catch(_com_error &e)
{
_bstr_t bstrSource(e.Source());
_bstr_t bstrDescription(e.Description());
TRACE("Exception thrown for classes generated by #import");
TRACE("\tCode=%081x\n",e.Error());
TRACE("\tCode meaning=%s\n",e.ErrorMessage());
TRACE("\tSource=%s\n",(LPCTSTR)bstrSource);
TRACE("\tDescription=%s\n",(LPCTSTR)bstrDescription);
}
DWORD dwError = ::GetLastError();
CFrameWnd::OnClose();
dwError = ::GetLastError();
//::PostQuitMessage(0);
}
解决方案 »
- 问题又来了,怎么取消投递的IO?
- 我从数据库中读取了一个表中的数据,数据有父子节点,该怎么定义结构体把数据放进去,然后用来建立一个树。
- 求帮忙!!!关于消息映射宏的问题!!!
- VC++ 如何调用OCX组件
- 如何把多个对话框控件关联到一个变量?
- 怎样让程序在WinXP环境中找到启动目录。
- 吐血送分,高手请进(连接池,对像池,线程池)
- ODBC的CRecord中怎么调带输出参数的存储过程?
- 紧急求助:CRecordSet问题
- 如何在view中实现button?
- 如何得到用户在list的选择?
- 在CMainFrame::OnAppExit()中,调用CFrameWnd::OnClose(),应用程序退不出来?急!!!!!!
m_pEquipErrListDlg->DestroyWindow();
delete m_pEquipErrListDlg;第二个错误好像有对象没释放,加这个
g_ConnectPtr->Release();区定所有对象都释放了在调用::CoUninitialize();