Home arrow Delphi-Kylix arrow Page 4 - Creating a WHOIS Lookup Client
DELPHI-KYLIX

Creating a WHOIS Lookup Client


In this article we are going to create a whois lookup client application. The main aim of this application will be to look up information about websites on various known WHOIS servers.

Author Info:
By: Jacques Noah
Rating: 5 stars5 stars5 stars5 stars5 stars / 3
September 18, 2006
TABLE OF CONTENTS:
  1. · Creating a WHOIS Lookup Client
  2. · DNS Resolution
  3. · The Program
  4. · Entire Code

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
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.

blog comments powered by Disqus
DELPHI-KYLIX ARTICLES

- Loading an XML Document into the DOM
- Delphi Wrapper Classes and XML
- Delphi and the DOM
- Delphi and XML
- Internet Access: Client Service
- Finishing the Client for an Internet Access ...
- The Client for an Internet Access Control Ap...
- User Management for an Internet Access Contr...
- Important Procedures for an Internet Access ...
- Server Code for an Internet Access Control A...
- Constructing the Interface for an Internet A...
- Building a Server Application for an Interne...
- Building an Internet Access Control Applicat...
- Client Dataset: Working with Data Packets an...
- Using the Client Dataset in an N-Tiered Appl...

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 11 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials