Solved

MAC Addresses on Network

Posted on 2000-05-08
6
126 Views
Last Modified: 2010-04-04
I am using both D3 and D5. I am in search of Delphi code and/or documentation that will allow me to do the following on an NT 4.x/5.x/2000 network:

From a single workstation (presumably an NT workstation but I suppose it could be a Win9X workstation) logged into this NT domain I would like to be able to be able to determine the IP address of every other workstation that is currently logged into the same domain, and (more importantly) determine the hardware MAC address of every other workstation that is currently logged into this domain.

All of the above is quite simple to do in a Novell environment but I have been searching for weeks for a way to do this on an NT network. Any help would be greatly appreciated!

Regards,

Chris

0
Comment
Question by:cdk033198
  • 3
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Madshi
ID: 2789529
You should post a link to this question in the "Windows programming" forum. This sounds like a quite difficult question, so it would surely help to make the C++ guys look at this question, too.
0
 
LVL 15

Expert Comment

by:simonet
ID: 2789830
Piece of cake!

The hardest part, but still not impossible is to enumerate the MAC address. There are no remote calls that will retrieve that, so you'll have to create a "listener" for that, which will install on Windows (9x/NT/2k) as a service, so it's invisible.

The listener service works pretty much like Microsoft SMS, BackOriffice, Netbus, etc.: it's a program that listens do a specific TCP/IP port (you define what port it is), and responds to specific commands. The commands are sent out by the server machine (which contains the server app). One of the commands can be something like "#GET-MAC-ADDR@", and then the host machine reads (locally) the MAC addr and sends it over the TCP/IP port.

Enumerating the IP addresses in the local network is easier. There are functions that will let you enumerate all machines on a given LAN. YOu simply get the machine's name and convert it to its IP addr. The enumeration code can be found at http://www.delphifreestuff.com/examples/wnetexmp.html

I have some source code at home that I'll send you later on with all this I am talking about.

Yours,

Alex
0
 
LVL 15

Accepted Solution

by:
simonet earned 300 total points
ID: 2789839
To get the IP from the enumerated machine name, use the function below:

Now, the second step is to get the IP for each machine found. For that you can use the function below, passing the name of the machine as the parameter:

uses WinSock;

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



Alex
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

Author Comment

by:cdk033198
ID: 2844870
Comment accepted as answer
0
 

Author Comment

by:cdk033198
ID: 2844871
Thank you. Sorry for delay in closing this question.
0
 
LVL 15

Expert Comment

by:simonet
ID: 2845016
>Thank you.

Anytime, cdk! Thanks.

Alex
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Machine not responding during CopyFile() 3 98
FMX StringGrid1->Canvas->FillRect Problem 3 150
oracle global variables 4 68
Convert a string into a TDateTime 5 60
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

808 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