using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Management;
using System.Net.NetworkInformation;
namespace test
{
public static class MacAddress
{
public static string GetMacAddress()
{
const int MIN_MAC_ADDR_LENGTH = 12;
string macAddress = string.Empty;
long maxSpeed = -1;
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;
}
}
return macAddress;
}
}
}
2015년 5월 21일 목요일
C# Get Clinent MacAddress
피드 구독하기:
덧글 (Atom)