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.
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
You 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/.
Thanks for sharing