1、編譯沒有錯(cuò)誤。
--------------------Configuration: EastR - Win32 Debug--------------------
EastR.exe - 0 error(s), 0 warning(s)
2、運(yùn)行到某一個(gè)函數(shù)報(bào)錯(cuò)
3、調(diào)試到int m_ClockNo = atoi(NewNo->GetItemText(0,0).GetBuffer(NewNo->GetItemText(0,0).GetLength()));
報(bào)Unhandled exception in EastR.exe (MFC42D.DLL) :0xC0000005;Access Violation錯(cuò)誤
附錯(cuò)誤函數(shù)代碼:
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("聯(lián)機(jī)失敗!");
}
else
{
if(SetClockID(hPort,New_id))
{
AfxMessageBox("新機(jī)號(hào)設(shè)置成功!");
}
else
AfxMessageBox("修改機(jī)號(hào)失敗!");
}
ClosePortHandle(hPort);
UnCallClock(hPort);
}
}