您可以使用System.Net.NetworkInformation命名空间中的NetworkInterface类来获取本机的MAC地址。下面是一个示例代码:

using System;
using System.Net.NetworkInformation;

class Program
{
    static void Main(string[] args)
    {
        NetworkInterface[] networkInterfaces = NetworkInterface.GetAllNetworkInterfaces();
        
        foreach (NetworkInterface networkInterface in networkInterfaces)
        {
            if (networkInterface.OperationalStatus == OperationalStatus.Up)
            {
                PhysicalAddress physicalAddress = networkInterface.GetPhysicalAddress();
                Console.WriteLine("MAC地址: " + physicalAddress.ToString());
            }
        }
        
        Console.ReadLine();
    }
}

请注意,您需要在项目中引用System.Net.NetworkInformation命名空间

WPF 获取本机mac地址

原文地址: https://www.cveoy.top/t/topic/i0ic 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录