Reg Getting MAC(Media Access Control ) address of a mobile connect

J

Jayanth Nadig

Hi All,

I am trying to get MAC(Media Access Control ) address of a mobile
connected in Bluetooth network programmatically through C#.I am using
Visual Studio 2005. Please help me.
 
E

eric

You'll have to use OpenNetCF for the following but this works

public static string GetMacAddress()

{

const int numSignificantBytes = 6;

StringBuilder st = new StringBuilder();

AdapterCollection aC = Networking.GetAdapters();

foreach (Adapter a in aC)

{

if (a.Type == AdapterType.Ethernet)

{

byte[] mAddress = a.MacAddress;

if (mAddress == null || mAddress.Length < numSignificantBytes) continue;

for (int ii = 0; ii < numSignificantBytes; ii++)

{

if (ii > 0) st.Append(':');

st.Append(mAddress[ii].ToString("X2"));

}

return st.ToString();

}

}

throw new AdapterException("No Ethernet adapter found");

}
 

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