本文整理自网络,侵删。
uses
winsock;
function GetHostIp_wwwdelphitopcom(HostName: string): string;
type
tAddr = array[0..100] of PInAddr;
pAddr = ^tAddr;
var
I: Integer;
WSA: TWSAData;
PHE: PHostEnt;
P: pAddr;
begin
Result := '';
WSAStartUp($101, WSA);
try
PHE := GetHostByName(pansichar(ansistring(HostName)));
if (PHE <> nil) then
begin
P := pAddr(PHE^.h_addr_list);
I := 0;
while (P^[I] <> nil) do
begin
Result := (inet_nToa(P^[I]^));
Inc(I);
end;
end;
except
end;
end;
相关阅读 >>
Delphi 双击listbox1内容,数据插入到memo1/synedit1鼠标指定位置
Delphi 7 + gdiplus 简单实现双缓冲绘制移动图形
Delphi 2009 indy10 idhttp get 中文出现乱码的问题
更多相关阅读请进入《Delphi》频道 >>