如何获取在我的PC中连接的Usb加密狗的Mac地址? [英] How Can I Get The Mac Address Of Usb Dongle Which Is Connected In My Pc?
本文介绍了如何获取在我的PC中连接的Usb加密狗的Mac地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取在我的PC中连接的usb加密狗的mac地址-using c#?
解决方案
你好
你可以从这个代码获得所有网络
你可以找到你的加密狗并获得你的mac地址
< pre lang =c#> foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
{
string tempMac = nic.GetPhysicalAddress()。ToString();
if (nic.Speed > maxSpeed&&
!string .IsNullOrEmpty(tempMac)&&
tempMac.Length > = MIN_MAC_ADDR_LENGTH)
{
maxSpeed = nic.Speed;
macAddress = tempMac;
}
}
USB设备没有MAC地址,以太网接口可以。
如果您的USB加密狗是以太网适配器,则上述代码可以正常工作。
How can i get the mac address of usb dongle which is connected in my PC -using c#?
解决方案
Hello
you can get all network from this code
you can find your dongle and get you mac address
foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces()) { string tempMac = nic.GetPhysicalAddress().ToString(); if (nic.Speed > maxSpeed && !string.IsNullOrEmpty(tempMac) && tempMac.Length >= MIN_MAC_ADDR_LENGTH) { maxSpeed = nic.Speed; macAddress = tempMac; } }
USB devices don't have MAC addresses, Ethernet interfaces do.
If your "USB dongle" is a Ethernet adapter, then the above code can work.
这篇关于如何获取在我的PC中连接的Usb加密狗的Mac地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文