How to retriever network computer's Host Name and Mac Address?

M

martin lanny

Simple network scanner is a part of my dotnet solution. It pings ip
addresses in a selected network range and gives me the response time for
each computer it finds.

Anyhow, I would need to retrieve two more pieces of information for each
active (local network) IP address:

- Computer's Host Name
- Mac Address

Can someone give me an example of how to do so?
I've have this working in Delphi, but I need to port this functionality
into my dotnet version of the program.

Thank you for your time, your help is really appreciated.

Martin
 
N

Nicholas Paldino [.NET/C# MVP]

Martin,

You might be able to get the host name through the static GetHostEntry
method on the Dns class, but I don't know that it will give you the NETBIOS
name (which is what I think you are after).

As for getting the mac address, you will have to connect to the WMI
provider on the host machine and then query for the Win32_NetworkAdapter
instance that corresponds to the IP address (which you will have to join in
the WMI query with the appropriate Win32_NetworkAdapterConfiguration
instance) to get the mac address.

How were you doing it in Delphi? If you were using Windows APIs, then
you might find it easier to just translate the calls into .NET.
 
K

Kerem Gümrükcü

Hi Martin,

visit my Page, scroll down on the right side until you
find the "NetworkInformationNET" Project. It is
exactly what you are looking for, open source and
with full source code included. Its written in C++.NET
but you will easily translate it to C#....

Sign my guestbook ( i need some entries, its new :)...)

http://entwicklung.junetz.de/

Cheers

Kerem

---------
New Open Source Tools from me:
Calculate MD5 or SHA1 Hash for Files!
KHash Tools 1.0 Englisch:
http://download.chip.eu/de/KHash-Tools-1.0_1317168.html
http://entwicklung.junetz.de/projects/opensource/khashtools/khashtools v.1.0.zip
---------

Beste Grüsse / Best regards / Votre bien devoue

Kerem Gümrükcü
(e-mail address removed)

Best Quote: "Ain't nobody a badass with a double dose
of rock salt...", Kill Bill Vol.2

Latest Open-Source Projects: http://entwicklung.junetz.de
Sign my guestbook: http://entwicklung.junetz.de/guestbook/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top