Retrieving MAC Address in Compact Framework

Posted: August 2, 2007 in .Net Compact Framework
Recently I have seen that getting the MAC address of a Pocket PC network card using the .Net Compact Framework requires calling to the APIiphlpapi.dll‘. This is because the Windows Management Instrumentation (WMI) classes are not in Compact Framework. Otherwise you should have used WMI to get the MAC address.
But believe me that the process involved in Compact Framework to get the MAC address is complex. So as a suggestion I would say to use the OpenNETCF class libraries. You have to use OpenNETCF.Net and OpenNETCF to successfully get the MAC address. If you want to know what is happening underneath you also can download the OpenNETCF source code too. 
OpenNETCF web site is, visit them and see.
The code for getting the MAC address of the first adapter using OpenNETCF would be,

‘ Creating a variable to hold all the retrieved adapters.


adpcol As OpenNETCF.Net.AdapterCollection = OpenNETCF.Net.Networking.GetAdapters

If adpcol.Count = 1 Then

‘ adpcol.Item(0).MacAddress will be returning in Byte stream, you have to use Bit Converter to convert the stream to string.

GetDeviceMAC = BitConverter.ToString(adpcol.Item(0).MacAddress)


GetDeviceMAC =

"No Adapters Fetched"

End If

(You have to refer OpenNETCF.Net and OpenNETCF to make this code run.)



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s