delphi2010 域名转换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;

原文地址:https://www.cnblogs.com/xtfnpgy/p/9285393.html