1. 程式人生 > >MFC異常處理機制,獲取異常引起的錯誤

MFC異常處理機制,獲取異常引起的錯誤

try
{
檢測的程式碼
}
catch(CException* e)
{
TCHAR szCause[255];
CString strFormatted;

e->GetErrorMessage(szCause, 255);
strFormatted = _T("The data file could not be opened because of this error: ");
strFormatted += szCause;
AfxMessageBox(strFormatted);
}