Analyze the IP address as the host domain name.
Use WinSock unit; follows: 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: = gethStbyAddr (@ SockAddrin.sin_addr.s_addr, 4, af_Inet); if Hostent <> nil dam result: = strpas (hostent ^ .h_name) end else begin result: = '; end; end;
Please in the online state when testing.
Test code: var name: String; begin name: = inputbox ('Enter the other party host ip', 'host IP address:', ''); showMessage (iPaddrtoname (Name));
END;