Creating a WHOIS Lookup Client - Entire Code
(Page 4 of 4 )
For your convenience, here is the entire code for the program, all in one place.
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,
Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, IdTCPConnection, IdTCPClient,
IdWhois,
IdBaseComponent, IdComponent, IdTCPServer, IdWhoIsServer,
IdDNSResolver,
IdCustomTCPServer, ComCtrls, Buttons;
type
TForm1 = class(TForm)
Panel2: TPanel;
IdWhoIsServer1: TIdWhoIsServer;
IdWhois1: TIdWhois;
IdDNSResolver: TIdDNSResolver;
Panel3: TPanel;
Panel4: TPanel;
hname: TEdit;
cb: TComboBox;
Panel5: TPanel;
g_info: TBitBtn;
StaticText1: TStaticText;
StaticText2: TStaticText;
Memo1: TMemo;
lv: TListView;
hostnme: TEdit;
StaticText3: TStaticText;
resolve: TBitBtn;
StatusBar1: TStatusBar;
dns: TEdit;
StaticText4: TStaticText;
StaticText5: TStaticText;
procedure g_infoClick(Sender: TObject);
procedure resolveClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
li:tlistitem;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.g_infoClick(Sender: TObject);
begin
memo1.Clear;
//label1.Caption:='Connected';
with IdWhois1 do begin
Host :=cb.text;
memo1.Lines.Text := whois(trim(hname.text));
end;
//idWhois1.Disconnect;
end;
procedure TForm1.resolveClick(Sender: TObject);
var
Count: Integer;
DNSServer: String;
HostName: String;
I: Integer;
begin
Memo1.Lines.Clear;
DNSServer:=dns.Text;
HostName:=hostnme.Text;
if (DNSServer='')or(HostName='') then
begin
Memo1.Lines.Add('*** Error ***');
if DNSServer='' then
Memo1.Lines.Add('DNS Server is empty.');
if HostName='' then
Memo1.Lines.Add('Host name is empty.');
Exit;
end;
IdDNSResolver.Host:=DNSServer;
IdDNSResolver.QueryType:=[qtA];
IdDNSResolver.Resolve(HostName);
Count:= IdDNSResolver.QueryResult.Count;
if Count=0 then Exit;
for I:=0 to Count-1 do
begin
if IdDNSResolver.QueryResult.Items[I] is TARecord then
li:=lv.Items.Add;
with TARecord( IdDNSResolver.QueryResult[I]) do begin
//Memo1.Lines.Add(ClassName+': '+Name+' resolves to IP
address '+IPAddress);
li.Caption:=Name;
li.SubItems.Add(IPaddress);
end;
end;
end;
end.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |