1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
uses WinSock; function TForm_Main.GetIPName(IP: String): String; var WSAData: TWSAData; sin: TSockAddrIn; pHost: PHostEnt; begin WSAStartup($0202, WSAData); sin.sin_family := AF_INET; sin.sin_addr.S_addr := Inet_Addr(pChar(IP)); pHost := gethostbyaddr(Pointer(@sin.sin_addr), 4, PF_INET); if pHost <> nil then begin Result := pHost^.h_name; end else begin Result := ''; end; WSACleanup; end; |
최신 댓글