Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get MAC address from Windows-mobile?

how to get MAC address from Windows-mobile using C# code ?

thank in advance

like image 593
Gali Avatar asked Jul 17 '11 07:07

Gali


2 Answers

please go through below pasted links hope this will help you to find the mac address of the device

MAC address in Compact Framework

How to Get MAC address programatically in c# for a windows mobile 6.0 device

like image 187
Prabhakantha Avatar answered Oct 14 '22 19:10

Prabhakantha


      [DllImport("iphlpapi.dll", SetLastError = true)]
  public static extern int GetAdaptersInfo(byte[] info, ref uint size);

  /// <summary>
  /// Gets the Mac Address
  /// </summary>
  /// <returns>the mac address or ""</returns>
  public static unsafe string GetMacAddress()
  {
     uint num = 0u;
     GetAdaptersInfo(null, ref num);
     byte[] array = new byte[(int)((UIntPtr)num)];
     int adaptersInfo = GetAdaptersInfo(array, ref num);
     if (adaptersInfo == 0)
     {
        string macAddress = "";
        int macLength = BitConverter.ToInt32(array, 400);
        macAddress = BitConverter.ToString(array, 404, macLength);
        macAddress = macAddress.Replace("-", ":");

        return macAddress;
     }
     else
        return "";
  }
like image 26
user2060763 Avatar answered Oct 14 '22 20:10

user2060763