How can i get the ip address if i know the domain name ?

Posted on 2004-12-01
Last Modified: 2010-04-05
how can i get the ip address if i know the domain name ?
Question by:wwwbetyar
    LVL 17

    Expert Comment


    You need to know the computer name. A domain is a set of computers and doesn't have an IP address.

    uses Winsock;

    function GetRemoteIPAddress(ComputerName : string) : string;
      wsdata : TWSAData;
      he : PHostEnt;
      ss : pchar;
      ip : TInAddr;
      WSAStartup(MakeWord(1, 1), wsdata);
      he := gethostbyname(pchar(ComputerName));
      if he<>nil then begin
        ip.S_addr := integer(pointer(he^. h_addr_list^)^);
        ss := inet_ntoa(ip);
        Result := string(ss);

    procedure TForm1.Button1Click(Sender: TObject);
      ShowMessage(GetRemoteIPAddress(Edit1.Text)); // the computer name is without '\\'

    Regards, Geo
    LVL 5

    Accepted Solution

    You may want to have a look at the Internet Components Suite at

    The TDnsQuery component may do what you want.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
    In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now