下面这段程序调试通过:theHostName运行结果为:'www.delphibbs.com'
Uses WinSock, SysUtils;
var Phe: PHostEnt;
// HostEntry buffer for name lookup
theHostName, HostIP: String;
addr: Integer;
wsaInitData: WSADATA;
begin
// If used with other code, you may not need WSAStartup
// WSAStartup(1, wsaInitData);
addr := inet_addr(PChar('209.143.154.82'));
Phe := GetHostByAddr(@addr, sizeof(integer), PF_INET);
if Phe <> Nil then
begin
// Addr := longint(plongint(Phe^.h_addr_list^)^);
theHostName := Phe^.h_name;
// HostIP := StrPas(inet_ntoa(TInAddr(Addr)));
end;
// You may not cleanup if other code still needs WinSock
// WSACleanup;
end.