Delphi-Kylix
  Home arrow Delphi-Kylix arrow Page 3 - Creating a WHOIS Lookup Client
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Moblin 
JMSL Numerical Library 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
DELPHI-KYLIX

Creating a WHOIS Lookup Client
By: Jacques Noah
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2006-09-18

    Table of Contents:
  • Creating a WHOIS Lookup Client
  • DNS Resolution
  • The Program
  • Entire Code

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Creating a WHOIS Lookup Client - The Program


    (Page 3 of 4 )

    In addition to looking up website information, our application is also going to have the additional functionality of converting hostnames to IP addresses.

    Create a new application, and drop 4 Tpanels, two buttons (rename them to "resolve" and "g_info"), a memo, four static labels, three Tedits (rename them to "hostname," "hname" and "dns"), a TCombobox renamed to "cb" and a listview renamed to "lv." Add an idwhois and idDNS component from the Indy Clients tab. Arrange them so that they look something like this:

    Finally, add a new form and save it as "addwhois." Put one edit, a button and a label on it. Save it all.

    Double click on the GetInfo button and add the following code:

    procedure TForm1.g_infoClick(Sender: TObject);
    begin
    memo1.Clear;
     with IdWhois1 do begin
        Host :=cb.text;
        memo1.Lines.Text := whois(trim(hname.text));
     end;

    All that the code above does is look up information about the hostname provided. The hostname above refers to the location of the WHOIS database. Examples include whois.internic.net, arin.net, etc.  The data that is returned is displayed in the memo.

    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
          li.Caption:=Name;
        li.SubItems.Add(IPaddress);
        end;
        end;
       end;

    The code above takes two parameters: dnsserver and the hostname. The dnsserver is typically an IP address, such as 192.168.0.1. This is needed to resolve the given host name to an IP address(es) that will return the requested information from that web site. The host name is any domain name, such as www.mysite.com.

    procedure TForm2.Button1Click(Sender: TObject);
    begin
    form1.cb.items.add(edit1.Text);
    close;
    end;

    The code above allows you to add more WHOIS server locations to the drop down box. The more locations you provide, the fuller the information you get about a specific domain.

    More Delphi-Kylix Articles
    More By Jacques Noah


       · I hope you found my article educational; I welcome your comments.
     

    DELPHI-KYLIX ARTICLES

    - Building an Internet Access Control Applicat...
    - Client Dataset: Working with Data Packets an...
    - Using the Client Dataset in an N-Tiered Appl...
    - Using the Client Dataset in Two-Tiered Clien...
    - Using the Client Dataset in File-Based Archi...
    - Demystifying the Client Dataset
    - Working with INI Files in Delphi
    - Creating Data Link (UDL) Files in Delphi
    - Looking at the Details for an Invoicing Appl...
    - Invoicing in Delphi: Show Me the Money
    - Saving Images and Binary Files to a Database...
    - Saving Files to a Database using Delphi: Sav...
    - Creating CF Applications and Integrating a S...
    - Using Try and Finally to Help Prevent Memory...
    - The Implementation of an FTP Server







    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway