How to get the MAC address from Windows-mobile?

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

Thanks in advance

+5
source share
2 answers

please review the links below, hoping this helps you find the MAC address of the device.

MAC Address in Compact Framework

How to get MAC address programmatically in C # for Windows Mobile 6.0 device

+4
source
      [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 "";
  }
+2
source

All Articles