Click here to Skip to main content
12,702,969 members (30,739 online)
Click here to Skip to main content
Add your own
alternative version


37 bookmarked

WhoIS Class for MFC

, 29 Feb 2000
Rate this:
Please Sign up or sign in to vote.
A simple MFC class for WhoIS processing for the Internet.
  • Download demo project - 44 Kb
  • Sample Image - Whois.jpg

    This is a simple MFC class for Internet-based WhoIs processing. WhoIs is an internet function to determine information about specific IP addresses and domain names. A number of companies, such as NetworkSolutions and Internic, keep WHOIS databases online at all times. While many freeware applications exist to display this data, there is little information or code available that actually does it.

    Many applications need access to this information, and this class provides a simple way to query these databases. The code to use this class to access this information would look like the following:

    // Create class instance
    CWhoIsClass whoIs;
    // Set address to be queried
    CString szAddress = "";
    // Call actual function
    CString szResult = whoIs.WhoIs(szAddress);

    There are only two public functions for the class:

    CString WhoIs(LPCSTR szAddress);
    void SetWhoIsServer(LPCSTR szServerName);

    The first is used to obtain the WhoIs information. The data is returned as a string that is typically a few hundred characters.

    The second is used to change WhoIs servers. The program defaults to the server. You can change it to whatever whois server best fits your needs. The Internic and Network Solutions servers host mostly US sites. Other servers exist to handle military address and international addresses. You should probably expect to query two or more servers to obtain the best information.

    When querying a whois server, you can request either domain name information (eg. or IP address information (eg. For example, the following would be valid address queries:




    would be an invalid query request.

    Most whois servers appear to accept the domain portion (minus the "www." part) and return valid information. The query syntax for IP address requests varies by whois server The server accepts pure IP address queries. The server however requires that the word "host" preceed the IP portion. If you use the network solutions whois server, which sometimes returns more complete information, your queries would have to take the following form:


    If the "host" part is missing, no data will be returned with using the server.

    Using the code in your project also requires you include the source and header files for the CWhoIsClass. This would usually look like this:

    #include "WhoIsClass.h"
    #include "WhoIsClass.cpp"

    The code was compiled with VC++ 6.0, but should work with earlier versions as well.  It uses MFC sockets for processing, and therefore requires a AfxSocketInit() call prior to class use. It assumes a connection to the Internet already exists.

    That's it. Not very complicated, but it solved my problem. Perhaps it will help others as well. <p>


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    Ed Dixon
    Web Developer
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    GeneralNew whois server URL Pin
    dimag30-May-07 8:57
    memberdimag30-May-07 8:57 
    Generalbeginer Pin
    dnqhung12-Jun-04 21:31
    memberdnqhung12-Jun-04 21:31 
    GeneralCWhoIsClass::WhoIs Bug Pin
    qiek19-Feb-04 19:30
    memberqiek19-Feb-04 19:30 
    GeneralNeat !! Pin
    WREY13-Apr-03 0:05
    memberWREY13-Apr-03 0:05 
    GeneralUnable to use IP Address Pin
    M.Fletcher6-Jun-02 20:11
    memberM.Fletcher6-Jun-02 20:11 
    Generalserver to connect to get info Pin
    pankaj24-Sep-01 22:59
    memberpankaj24-Sep-01 22:59 
    GeneralRe: server to connect to get info Pin
    Laurent Sarrazin1-Oct-01 3:17
    memberLaurent Sarrazin1-Oct-01 3:17 
    GeneralRe: server to connect to get info Pin
    Yaoer16-Jan-02 17:19
    memberYaoer16-Jan-02 17:19 
    GeneralThe App Runs only with MFC42D.dll Pin
    Sujatha Bhandari3-Jun-00 4:41
    sussSujatha Bhandari3-Jun-00 4:41 
    GeneralRe: The App Runs only with MFC42D.dll Pin
    se-hyung, kim27-Jun-01 5:07
    memberse-hyung, kim27-Jun-01 5:07 
    GeneralRe: The App Runs only with MFC42D.dll Pin
    Ed Dixon27-Jun-01 5:10
    memberEd Dixon27-Jun-01 5:10 
    GeneralWhois Class Pin
    Dick Adams6-Mar-00 5:19
    sussDick Adams6-Mar-00 5:19 
    GeneralRe: Whois Class Pin
    Ed Dixon6-Mar-00 18:44
    sussEd Dixon6-Mar-00 18:44 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web02 | 2.8.170118.1 | Last Updated 1 Mar 2000
    Article Copyright 2000 by Ed Dixon
    Everything else Copyright © CodeProject, 1999-2017
    Layout: fixed | fluid