locating mac address with vb.net app

Hello experts, i got a request to locate all the mac address on our network, but I am not sure where to start.  I found some sample code using the System.Management namespace.  The problem is where do i get the management namespace, because i cant find it?  I just need the namespace to make it work

Here is some sample code

 Dim mc As System.Management.ManagementClass
      Dim mo As ManagementObject
      mc = New ManagementClass("Win32_NetworkAdapterConfiguration")
      Dim moc As ManagementObjectCollection = mc.GetInstances()
      For Each mo In moc
         If mo.Item("IPEnabled") = True Then
            ListBox1.Items.Add("MAC address " & mo.Item("MacAddress").ToString())
         End If
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have to reference the System.Management assembly. Right click on References in your Solution explorer and click Add Reference. System.Management should be in the list.

That said, the Win32_NetworkAdapterConfiguration will only return entries for the local machine adapters. The only way i know how to retrieve all the MAC addresses on the network is to do PING, or better yet ARP, sweeps across the subnet.
tentavariousAuthor Commented:
Could you elaborate more ARP?  I found the reference so you will be getting the points, I would like a little more info on this subject though, thanks.
Sure thing,

The API is the IPHelper API in Win32. Not sure if there is a .NET equivalent. There are lots of useful networking functions in there, one of which is SendARP.

Basic call:

IPAddr ipAddr = inet_addr (ipToArp);
memset (pulMac, 0xff, sizeof (pulMac));
HRESULT hr = SendARP(ipAddr, 0, pulMac, &ulLen);

Basically, you would just put that in a loop and sweep based on IP/subnet combo (which you could retrieve from the Win32_NetworkAdapterConfiguration WMI call).

I'll have this code implemented somewhere in a test app. If i can dig it up i'll shoot you a link.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tentavariousAuthor Commented:
Please shoot me a link if you can find it, thanks.
I found my mini-project that I did a while back. Took me a bit to get it back up into running condition. It still needs a few changes but it's in decent shape now.

You can find it here:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.