delphi 2010 域名转换IP


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;


联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678