?
Solved

retriving the computer of another pc given the ip address

Posted on 2003-03-05
3
Medium Priority
?
154 Views
Last Modified: 2010-04-04
how do you retrieve the computer name of another pc given the ip address only?
0
Comment
Question by:khangski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 160 total points
ID: 8078212
Hi,

Try this:

uses Winsock;

function GetRemoteHostName(IPAddr : string) : string;
var
  wsdata : TWSAData;
  he : PHostEnt;
  ip : TInAddr;
begin
  WSAStartup(MakeWord(1, 1), wsdata);
  ip.S_addr := inet_addr(PChar(IPAddr));
  he := gethostbyaddr(@ip.S_un_b, 4, AF_INET);
  if he<>nil then
    Result := string(he.h_name)
  else
    Result := IntToStr(WSAGetLastError);
  WSACleanup();
end;

// usage:
procedure TForm1.Button1Click(Sender: TObject);
begin
  ShowMessage(GetRemoteHostName('192.0.0.1'));
end;

Regards, Geo
0
 

Author Comment

by:khangski
ID: 8084840
thanks man...
0
 
LVL 17

Expert Comment

by:geobul
ID: 8086562
You are welcome ;-)
0

Featured Post

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 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