在看别人写的一段串口程序,对串口状态设置之后对异常的捕获为什么是这样的,CMemoryException,CFileException这些异常为什么捕获之后就清空指针没有做其他处理,而CException不是所有异常吗,为什么不只写这个.
bool CAAT_DriverDlg::OpenUart1(int comIndex)
{//这一段是 判断是否打开串口1
CString strOut;
g_hComWnd = AfxGetMainWnd()->m_hWnd;
try{
if (m_mscomm.get_PortOpen())
{
// m_mscomm.put_PortOpen(FALSE);
}
}
catch (CException* e)
{
e = NULL;
CString str;
str.Format(" No this COM %d", comIndex);
// MsgBox::str(str.GetBuffer(MAX_PATH));
return FALSE;
}
try
{
m_mscomm.put__CommPort(comIndex);//笔记本选择com
m_mscomm.put_InBufferSize(MAX_RECV_BUFF);//接收缓冲区 1024byte
m_mscomm.put_OutBufferSize(1024);//发送缓冲区 1024byte
m_mscomm.put_InputLen(0);//设置当前接收区数据长度为0,表示全部读取
m_mscomm.put_InputMode(1);// 以二进制方式检取数据
m_mscomm.put_RThreshold(1);//参数1表示每当串口接收缓冲区中有多于或等
//于1个字符时将引发一个接收数据的OnComm事件
m_mscomm.put_Settings(g_comInfo);//串口基本信息
}
catch (CMemoryException* e)
{
e = NULL;
}
catch (CFileException* e)
{
e = NULL;
}
catch (CException* e)
{
e = NULL;
CString str;
str.Format(" Unable to open COM %d", comIndex);
// MsgBox::str(str.GetBuffer(MAX_PATH));
AfxMessageBox(str);
return FALSE;
}