首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从Windows-mobile获取MAC地址?

如何从Windows-mobile获取MAC地址?
EN

Stack Overflow用户
提问于 2011-07-17 15:16:01
回答 2查看 8.3K关注 0票数 5

如何使用C#代码从Windows-mobile获取MAC地址?

提前感谢

EN

回答 2

Stack Overflow用户

发布于 2011-07-17 16:41:26

请通过下面粘贴的链接,希望这将帮助您找到设备的mac地址

MAC address in Compact Framework

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

票数 4
EN

Stack Overflow用户

发布于 2013-02-11 17:10:24

代码语言:javascript
复制
      [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 "";
  }
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6722466

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档