[Sample of June 9th] Get MAC of local Ethernet and Wireless80211 - Microsoft All-In-One Code Framework - Site Home - MSDN Blogs
Microsoft All-In-One Code Framework - Developers' Pain Killer

[Sample of June 9th] Get MAC of local Ethernet and Wireless80211

Rate This
  • Comments 1

 

Homepage image
image RSS Feed

Sample Download : http://code.msdn.microsoft.com/CSMACAddress-23db2a0a

Developed by Ruiz Yi, the sample demonstrates how to get the MAC of local Ethernet and Wireless80211 adapters or remote host using 3 approaches from C#.

1. Use Win32 WMI classes.
2. Use IP Helper APIs.
3. Use NDIS WMI classes.

Note:

1. To support IPv6 and the latest NDIS, this sample uses some APIs / WMI classes introduced in Windows Vista / Windows Server 2008 or later versions, so it must run on these OS version.

2. The result of local adapters using these approaches may vary, because WMI will get the adapters, and IP Helper APIs will get the network interfaces (including  some software loopback interfaces), you can add filters to get the specific interface type.

3. Using WMI to connect remote host, you must have the permission to access it, and may have to supply a valid credential.

4. Using IP Helper APIs to get the MAC, you don't have to supply the credential, but you can only get the hosts in the same subnet.     

5. If there is any issue while using WMI, you can check following documents:
 
  WMI Troubleshooting
  http://msdn.microsoft.com/en-us/library/aa394603(VS.85).aspx
 
  Connecting to WMI on a Remote Computer
  http://msdn.microsoft.com/en-us/library/aa389290(VS.85).aspx

  You can also download WMI Administrative Tools to check whether the WMI classes are available, or the remote host could be connected.
  http://www.microsoft.com/download/en/details.aspx?id=24045

For detailed introduction of the sample, please read the documentation at http://code.msdn.microsoft.com/CSMACAddress-23db2a0a

imageYou can find more code samples that demonstrate the most typical programming scenarios by using Microsoft All-In-One Code Framework Sample Browser or Sample Browser Visual Studio extension. They give you the flexibility to search samples, download samples on demand, manage the downloaded samples in a centralized place, and automatically be notified about sample updates. If it is the first time that you hear about Microsoft All-In-One Code Framework, please watch the introduction video on Microsoft Showcase, or read the introduction on our homepage http://1code.codeplex.com/.

Leave a Comment
  • Please add 4 and 2 and type the answer here:
  • Post
  • Thanks for sharing

Page 1 of 1 (1 items)