我想做一个网络监测的程序,就是不停通过ping一个地址,来判断网络是否正常。但我如果在测试中,拔掉网线,就会马上弹出Socket Error #10065错误,程序就会停止下来。我如果屏蔽了这个信息,程序也会停下来,而不是按照我的意愿去实现下一步操作,请问问题出在哪里呢?if Icmp.ReplyStatus.ReplyStatusType = rsErrorUnreachable then begin ... end;
为何我捕获错误后,只允许了一次代码,而不会持续运行下去呢? try ICMP.Host := ICMP_HOST.Text; while lblStart do begin ICMP.Ping; Application.ProcessMessages; Sleep(3000); //Application.ProcessMessages; end; except on E:EIdSocketError do begin //捕获错误 //if E.LastError >= 10065 then while E.LastError >= 10065 do //raise; begin //程序处理代码 neterror(); end; end end;
异常,已经中止了后面的代码。tools->debugger options->language Exceptions->Stop on Delphi Exceptions
try
ICMP.Host := ICMP_HOST.Text;
while lblStart do
begin
ICMP.Ping;
Application.ProcessMessages;
Sleep(3000);
//Application.ProcessMessages;
end;
except
on E:EIdSocketError do
begin
//捕获错误
//if E.LastError >= 10065 then
while E.LastError >= 10065 do
//raise;
begin
//程序处理代码
neterror();
end;
end
end;