?
Solved

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

Posted on 2004-12-01
2
Medium Priority
?
226 Views
Last Modified: 2010-04-05
how can i get the ip address if i know the domain name ?
0
Comment
Question by:wwwbetyar
2 Comments
 
LVL 17

Expert Comment

by:geobul
ID: 12714629
Hi,

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;
var
  wsdata : TWSAData;
  he : PHostEnt;
  ss : pchar;
  ip : TInAddr;
begin
  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);
  end;
  WSACleanup();
end;

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

Regards, Geo
0
 
LVL 5

Accepted Solution

by:
paulb1989 earned 250 total points
ID: 12717857
You may want to have a look at the Internet Components Suite at http://www.overbyte.be

The TDnsQuery component may do what you want.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Loops Section Overview
Suggested Courses
Course of the Month14 days, 10 hours left to enroll

840 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