Here is the procedure that does the lookup. If you look at the help for the
component you can work out which function to use for your application.
Note when getting an IP address it is returned as a single number which then
has to be translated into the four numbers.
procedure TMainForm.LookupClick(Sender: TObject);
var phe:PHostEnt;
IPAddr:U_long;
function DecToIp(IPA:u_long):string;
var G,H:string;
begin
H:=IntToHex(IPA,8);
Result:='';
repeat
if length(H)>8
then H:=Copy(H,length(H)-7,8)
else
if length(H)<8
then H:='0'+H;
until length(H)=8;
G:='$'+Copy(H,7,2);
Result:=Result+IntToStr(StrToInt(G));
G:='$'+Copy(H,5,2);
Result:=Result+'.'+IntToStr(StrToInt(G));
G:='$'+Copy(H,3,2);
Result:=Result+'.'+IntToStr(StrToInt(G));
G:='$'+Copy(H,1,2);
Result:=Result+'.'+IntToStr(StrToInt(G));
end;
begin
Screen.Cursor:=crHourGlass;
try
phe:=WSocketGetHostByAddr(Host.Text);
if phe<>nil
then Answer.Caption:=StrPas(Phe^.h_name)
else
begin
phe:=WSocketGetHostByName(Host.Text);
if phe <> nil
then
begin
IPAddr:=PInAddr(Phe^.h_addr_list^)^.s_addr;
Answer.Caption:=DecToIP(IPAddr);
end
else Answer.Caption:='N/A';
end;
Application.Title:='WinLookup - '+Answer.Caption;
finally
Screen.Cursor:=crDefault;
end;
end;
> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]On
> Behalf Of Jeremy Coulter
> Sent: Friday, 14 May 1999 09:33
> To: Multiple recipients of list delphi
> Subject: RE: [DUG]: NSLookup Component
>
>
> Thanks Patrick...I downloaded your wee app...very good....is it
> hard to get
> the winsock comp to do the lookup ?
>
> Thanks, Jeremy Coulter
snip
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz