void Scan::run()
{
char *temp,*csIP,*cdIP;
int len,exitCode;
QString tempIP,tempPing;
for(int x1=sIP[0];x1<=dIP[0];x1++)
for(int x2=sIP[1];x2<=dIP[1];x2++)
for(int x3=sIP[2];x3<=dIP[2];x3++)
for(int x4=sIP[3];x4<=dIP[3];x4++)
{
sprintf(temp,"%d.%d.%d.%d",x1,x2,x3,x4);
tempIP=(QString)(temp);
emit work("ping "+tempIP);
tempPing="ping "+tempIP+" -w 20"; //-w 20
exitCode = QProcess::execute(tempPing);
if(exitCode==0) emit work("sucessed!");
else emit work("failed!");
}
}
这个是对IP段的ping函数,work信号被触发后,从主线程里输出相应的消息。
每次ping完最后一个IP后,就会这样报错
NetworkSecurity.exe 中的 0x52bcd607 (Qt5Cored.dll) 处有未经处理的异常: 0xC0000005: 读取位置 0x2e323931 时发生访问冲突