Analyze the IP address as the host domain name.

zhaozj2021-02-08  190

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; Author: Latfi Baran

转载请注明原文地址:https://www.9cbs.com/read-3233.html

New Post(0)