求救:我在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);



}