Last active
July 25, 2018 13:32
-
-
Save edsoncelio/d138e5f318bee04b3cdfc8b6a7ce8ec6 to your computer and use it in GitHub Desktop.
Função para recuperar endereço MAC da interface Wlan0 em c#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void ShowNetworkInterfaces(Label label_mac) | |
{ | |
var end_mac=""; | |
IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); | |
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); | |
//nics[1] eh a interface wlan0, sendo : nics[1] = eth0, nics[2] = wlan0 | |
PhysicalAddress address = nics[2].GetPhysicalAddress(); | |
byte[] bytes = address.GetAddressBytes(); | |
for (int i = 0; i < bytes.Length; i++) | |
{ | |
end_mac += bytes[i].ToString("X2").ToString(); | |
} | |
//adicionar em uma label | |
label_mac.Text = "MAC: " + end_mac; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment