码迷,mamicode.com
首页 > Windows程序 > 详细

C#获取计算机MAC地址

时间:2017-08-13 00:03:40      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:ica   nice   c#   return   orm   pre   interface   ice   ring   

 

using System.Net.NetworkInformation;

public string GetMacAddress()
        {
            string physicalAddress = "";
            NetworkInterface[] nice = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface adaper in nice)
            {
                if (adaper.Description == "en0")
                {
                    physicalAddress = adaper.GetPhysicalAddress().ToString();
                    break;
                }
                else
                {
                    physicalAddress = adaper.GetPhysicalAddress().ToString();
                    if (physicalAddress != "")
                    {
                        break;
                    };
                }
            }
            return physicalAddress;
        }

 

C#获取计算机MAC地址

标签:ica   nice   c#   return   orm   pre   interface   ice   ring   

原文地址:http://www.cnblogs.com/htwzl/p/7351804.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!