Hi Peter, > I'm looking for a way to programmatically find the domain name(s) associated > with an IP address, like the various "whois" websites do. Any help?
This is some old code that I use, and still works, although you get the server behind the IP, not necessarily the domain name (there are often multiple domains behind an IP - look for 62.75.220.161 for example, which is the IP for www.bobswart.com but also www.erikswart.com etc. {$APPTYPE CONSOLE} uses Windows, WinSock; var wVersionRequested: Word; wsaData: TWSAData; var Str: String; IP: LongInt; Host: PHostEnt; begin try wVersionRequested := MAKEWORD(1,1); WSAStartup(wVersionRequested, wsaData); SetLength(Str,128); GetHostName(@Str[1],128); Host := GetHostByName(@Str[1]); writeln('Localhost: ',Host^.h_Name,' (=', inet_ntoa(PInAddr(Host^.h_addr_list^)^),')'); writeln; while not eof do begin readln(Str); write(Str,' is '); IP := inet_addr(PChar(Str)); Host := GetHostByAddr(@IP,SizeOf(IP),PF_INET); if Host <> nil then begin Str := Host^.H_name; if Pos('.',Str) > 0 then Delete(Str,1,Pos('.',Str)); writeln(Str) end else writeln('unknown') end finally WSACleanup end end. > Peter Laman Groetjes, Bob Swart -- Bob Swart Training & Consultancy (eBob42.com) Forever Loyal to Delphi Blog: http://www.drbob42.com/blog - RSS: http://drbob42.com/weblog.xml New Delphi 2006 Courseware e-books at http://www.eBob42.com/courseware __________________________________________________ Delphi-Talk mailing list -> Delphi-Talk@elists.org http://www.elists.org/mailman/listinfo/delphi-talk