...get the IP from a given URL?

Author: ZbySTr

Category: Internet / LAN

uses
  
Winsock;

function IAddrToHostName(const IP: string): string;
var
  
i: Integer;
  p: PHostEnt;
begin
  
Result := '';
  i      := inet_addr(PChar(IP));
  if i <> u_long(INADDR_NONE) then
  begin
    
p := GetHostByAddr(@i, SizeOf(Integer), PF_INET);
    if p <> nil then Result := p^.h_name;
  end
  else
    
Result := 'Invalid IP address';
end;

 

printed from
www.swissdelphicenter.ch
developers knowledge base