Delphi-Quellcode:
uses
WinSock;
function IPAddrToName(IPAddr: string): string;
var
SockAddrIn: TSockAddrIn;
HostEnt: PHostEnt;
WSAData: TWSAData;
begin
WSAStartup($101, WSAData);
SockAddrIn.sin_addr.s_addr := inet_addr(PChar(IPAddr));
HostEnt := gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);
if HostEnt <> nil then
Result := StrPas(Hostent^.h_name)
else
Result := '';
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(IPAddrToName('127.0.0.1'));
end;
Da es mit der lokalen
IP Adresse ganz fix geht, liegt es wohl am Netzwerk.