R
rainee
Unregistered / Unconfirmed
GUEST, unregistred user!
看下面代码:
host:=GetHostByName(Pchar(edit1.text));
如果edit1.text是127.0.0.1或192.168.0.1结果就不对了,192.168.1.1结果正常.是什么问题,大家帮帮我...
代码:
procedure TForm1.Button1Click(Sender: TObject);
var
hostHostent;
ip,ip1:string;
Err:Integer;
begin
try
host:=GetHostByName(Pchar(edit1.text));
except
err:=wsagetlasterror();
label1.caption:='error code:'+inttostr(err);
exit;
end;
ip:=copy(host.h_addr^,0,4);
ip1:=format('%d.%d.%d.%d',[ord(ip[1]),ord(ip[2]),ord(ip[3]),ord(ip[4])]);
edit2.text:=ip1;
end;
host:=GetHostByName(Pchar(edit1.text));
如果edit1.text是127.0.0.1或192.168.0.1结果就不对了,192.168.1.1结果正常.是什么问题,大家帮帮我...
代码:
procedure TForm1.Button1Click(Sender: TObject);
var
hostHostent;
ip,ip1:string;
Err:Integer;
begin
try
host:=GetHostByName(Pchar(edit1.text));
except
err:=wsagetlasterror();
label1.caption:='error code:'+inttostr(err);
exit;
end;
ip:=copy(host.h_addr^,0,4);
ip1:=format('%d.%d.%d.%d',[ord(ip[1]),ord(ip[2]),ord(ip[3]),ord(ip[4])]);
edit2.text:=ip1;
end;