2011-06-20 43 views
0

可能重复:
Reliable method to get machine's MAC address in C#如何获取要安装应用程序的系统的mac地址?

我想通过在应用程序,所以我可以用它在系统级授权代码来获得系统的MAC地址?

+0

重复的http://stackoverflow.com/questions/5908926/read-mac-address-and-c和http://stackoverflow.com/questions/850650/reliable-method-to-get-machines-mac -address-in-c和http://stackoverflow.com/questions/3157246/getting-mac-address-c等等。 –

+1

“the”mac地址?从Me Disappointment的回答中返回的地址可能是在安装期间临时连接到机器的无线网卡的地址。在MAC地址和系统之间没有1-1映射,因此将其用作授权或认证机制是一个非常糟糕的选择。 –

回答

0

您可以通过积极network interface得到它,如:

var mac = 
    (from item in NetworkInterface.GetAllInterfaces() 
    where item.OperationalStatus == OperationalStatus.Up 
    select item.GetPhysicalAddress()).FirstOrDefault(); 

从活动接口失败检索,可以考虑只抓住了环回地址。另外,如果你愿意,你可以循环这些元素,而不是使用Linq。

相关问题