1、编译没有错误。
--------------------Configuration: EastR - Win32 Debug--------------------
EastR.exe - 0 error(s), 0 warning(s)
2、运行到某一个函数报错
3、调试到int m_ClockNo = atoi(NewNo->GetItemText(0,0).GetBuffer(NewNo->GetItemText(0,0).GetLength()));
报Unhandled exception in EastR.exe (MFC42D.DLL) :0xC0000005;Access Violation错误
附错误函数代码:
void CChangeClockNo::OnOK()
{
// TODO: Add extra validation here
UpdateData(true);
int New_id = atoi(m_strNewID.GetBuffer(m_strNewID.GetLength ()));
int m_ClockNo = atoi(NewNo->GetItemText(0,0).GetBuffer(NewNo->GetItemText(0,0).GetLength()));
int m_Rate = atoi(NewNo->GetItemText(0,2).GetBuffer(NewNo->GetItemText(0,2).GetLength ()));
int Com = 1;
int nItem = 0;
HANDLE hPort;
hPort = OpenCommPort(Com,m_Rate);
if(!hPort)
{
AfxMessageBox("端口被占用!");
}
else
{
int Model;
double Ver;
int cls;
GetClockModel(hPort,Model,Ver,cls);
if(Ver==880 || Ver==889 || Ver==900)
{
SetCmdVerify(true);
}
if(!CallClock(hPort,m_ClockNo))
{
AfxMessageBox("联机失败!");
}
else
{
if(SetClockID(hPort,New_id))
{
AfxMessageBox("新机号设置成功!");
}
else
AfxMessageBox("修改机号失败!");
}
ClosePortHandle(hPort);
UnCallClock(hPort);
}
}