Thema: Delphi Indy und Ping

Einzelnen Beitrag anzeigen

CCRDude
(Gast)

n/a Beiträge
 
#10

Re: Indy und Ping

  Alt 2. Mai 2007, 13:00
Dann wäre das nicht GetHostByName, sondern GetHostByAddr:

Delphi-Quellcode:
function IPAddrToName(AIPAddr: string): string;
var SockAddrIn: TSockAddrIn;
    HostEnt: PHostEnt;
    WSAData: TWSAData;
begin
   WSAStartup($101, WSAData);
   try
      SockAddrIn.sin_addr.s_addr := inet_addr(PChar(AIPAddr));
      HostEnt := GetHostByAddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);
      if Assigned(HostEnt)
       then Result := StrPas(Hostent^.h_name)
        else Result := '';
   finally
      WSACleanup;
   end;
end;
  Mit Zitat antworten Zitat