PhysicalAddress クラス
アセンブリ: System (system.dll 内)


MAC アドレス (物理アドレス) は、コンピュータやプリンタなどの各ノードをネットワーク上で一意に識別するハードウェア アドレスです。
このクラスのインスタンスは、NetworkInterface.GetPhysicalAddress メソッドによって返されます。

ローカル コンピュータのすべてのインターフェイスの物理アドレスを表示するコード例を次に示します。
public static void ShowNetworkInterfaces() { IPGlobalProperties computerProperties = IPGlobalProperties.GetIPGlobalProperties(); NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces(); Console.WriteLine("Interface information for {0}.{1} ", computerProperties.HostName, computerProperties.DomainName); if (nics == null || nics.Length < 1) { Console.WriteLine(" No network interfaces found."); return; } Console.WriteLine(" Number of interfaces .................... : {0}", nics.Length); foreach (NetworkInterface adapter in nics) { IPInterfaceProperties properties = adapter.GetIPProperties(); // .GetIPInterfaceProperties(); Console.WriteLine(); Console.WriteLine(adapter.Description); Console.WriteLine(String.Empty.PadLeft(adapter.Description.Length,'=')); Console.WriteLine(" Interface type .......................... : {0}", adapter.NetworkInterfaceType); Console.Write(" Physical address ........................ : "); PhysicalAddress address = adapter.GetPhysicalAddress(); byte[] bytes = address.GetAddressBytes(); for(int i = 0; i< bytes.Length; i++) { // Display the physical address in hexadecimal. Console.Write("{0}", bytes[i].ToString("X2")); // Insert a hyphen after each byte, unless we are at the end of the // address. if (i != bytes.Length -1) { Console.Write("-"); } } Console.WriteLine(); } }

System.Net.NetworkInformation.PhysicalAddress


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


- PhysicalAddress クラスのページへのリンク