Click here to Skip to main content
15,890,557 members
Please Sign up or sign in to vote.
1.80/5 (2 votes)
See more:
How can i get the mac address of usb dongle which is connected in my PC -using c#?
Posted

Hello

you can get all network from this code
you can find your dongle and get you mac address

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;
              }
          }
 
Share this answer
 
Comments
Manivignesh 2-May-14 8:33am    
Thanks for the code...but i am getting all the network adapter info,in that how do i find my usb dongle mac address?
USB devices don't have MAC addresses, Ethernet interfaces do.

If your "USB dongle" is a Ethernet adapter, then the above code can work.
 
Share this answer
 
Comments
Nelek 2-May-14 13:35pm    
You are right, but...

If I am right in my guess, he is trying to bypass a licence dongle for a certain software. Those work combining info about the PC and the floating licence in the usb.
Dave Kreskowiak 2-May-14 14:29pm    
Yeah, but I'm not making any assumptions about what he's really doing.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900