当前位置:编程学习 > asp >>

ASP.NET获取客户端MAC地址

 /// <summary>
        /// get MacAddress
        /// </summary>
        /// <returns></returns>
        public static string GetMac()
        {www.zzzyk.com
            string MacAddress = String.Empty;
            ManagementClass mc = new ManagementClass("Win32_NetworkAdapterConfiguration");
            ManagementObjectCollection moc = mc.GetInstances();
            foreach (ManagementObject mo in moc)
            {
                if ((bool)mo["IPEnabled"] == true)
                {
                    MacAddress = mo["MacAddress"].ToString();
                    break;
                }
            }
            moc = null;
            mc = null;
// 将MAC地址用-分割
            MacAddress = MacAddress.Replace(":", "-");
            return MacAddress;
        }
补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,