如何获取MAC地址编程在C#中的是Windows Mobile 6.0设备 [英] How to Get MAC address programatically in c# for a windows mobile 6.0 device

查看:175
本文介绍了如何获取MAC地址编程在C#中的是Windows Mobile 6.0设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取MAC地址编程在C#中为Windows Mobile 6.0的设备?该System.Net.NetworkInformation不在,净compatc框架3.5的支持。

How to Get MAC address programatically in c# for a windows mobile 6.0 device? The System.Net.NetworkInformation is not supported in ,net compatc framework 3.5.

推荐答案

我知道它已经一段时间,但我需要这个,发现我可以使用OpenNETCF版本的code以上有一个调整:

I know it's been awhile, but I needed this and found I could use OpenNETCF version of the code above with a tweak:

INetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
//for each j you can get the MAC 
PhysicalAddress address = nics[0].GetPhysicalAddress();
byte[] bytes = address.GetAddressBytes();
for(int i = 0; i < bytes.Length; i++) {
    // Display the physical address in hexadecimal. 
    Console.Write("{0}", bytes[i].ToString("X2"));
    // Insert a hyphen after each byte, unless we are at the end of the address. 
    if(i != bytes.Length - 1) {
        Console.Write("-");
    }
}

这篇关于如何获取MAC地址编程在C#中的是Windows Mobile 6.0设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆