如何使用C#代码从Windows-mobile获取MAC地址?
提前感谢
发布于 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
发布于 2013-02-11 17:10:24
[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 "";
}https://stackoverflow.com/questions/6722466
复制相似问题