术语 | CException::GetErrorMessage | ||||||
释义 | CException::GetErrorMessage virtual BOOL GetErrorMessage(LPTSTR lpszError, UINT nMaxError, PUINT pnHelpContext = NULL); 返回值: 如果函数成功,则返回非零值;如果无错误信息文本,则返回0。 参数:
说明: 调用此成员函数提供有关所发生的错误的更多信息文本。例如,获取一个描述产生MFC在写一个CFile对象时出现CFileException异常的字符串。 注意: 此函数会拷贝多于nMaxError-1个字符到缓冲区,通常加一个空字符到结尾。如果缓冲区太小,错误信息将被截取。 示例: 以下是一个使用此成员函数的例子: CFile fileInput; CFileException ex; // try to open a file for reading. // The file will certainly not // exist because there are too many explicit // directories in the name. // if the call to Open() fails, ex will be // initialized with exception // information. the call to ex.GetErrorMessage() // will retrieve an appropriate message describing // the error, and we'll add our own text // to make sure the user is perfectly sure what // went wrong. if (!fileInput.Open("\\\\Too\\\\Many\\\\Bad\\\\Dirs.DAT", CFile::modeRead, &ex)) { TCHAR szCause[255]; CString strFormatted; ex.GetErrorMessage(szCause, 255); // (in real life, it's probably more // appropriate to read this from // a string resource so it would be easy to // localize) strFormatted = _T("The data file could not be opened because of this error: "); strFormatted += szCause; AfxMessageBox(strFormatted); else { // the file was opened, so do whatever work // with fileInput // we were planning... // : fileInput.Close(); } 请参阅:CException::ReportError |
||||||
随便看 |
|
MFC类库中文详解手册包含4274条MFC类库参考词条,基本涵盖了Microsoft基本类库中的类、全局函数、全局变量和宏的内容,是计算机编程的有利工具。