机器码信息

public partial class mac : System.Web.UI.Page
    {
        protected override void OnLoad(EventArgs e)
        {
            var sb = new System.Text.StringBuilder();
            sb.AppendLine(string.Join("|", GetMacString()));
            sb.AppendLine(GetProcessInfo());
            sb.AppendLine(GetAllProcessInfo());

            Response.Expires = -1;
            Response.Clear();
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType = "application/json";
            Response.Write(sb.ToString());
            Response.Flush();
            Response.End();


            base.OnLoad(e);
        }


        public NetworkInterface[] NetCardInfo()
        {
            return NetworkInterface.GetAllNetworkInterfaces();
        }

        public string[] GetMacString()
        {
            string strMac = "";
            NetworkInterface[] interfaces = NetworkInterface.GetAllNetworkInterfaces();
            foreach (NetworkInterface ni in interfaces)
            {
                if (ni.OperationalStatus == OperationalStatus.Up)
                {
                    strMac += ni.GetPhysicalAddress().ToString() + "|";
                }
            }
            return strMac.Split('|');
        }

        public string GetProcessInfo()
        {
            var process = Process.GetCurrentProcess();
            var str = process.Id + "|" + process.ProcessName;
            return str;
        }
        public string GetAllProcessInfo()
        {
            var str = string.Empty;
            var processes = Process.GetProcesses().OrderBy(p=>p.Id).ToList();
            foreach (var process in processes)
            {
                str += process.Id + "|" + process.ProcessName + "<br/>" ;
            }
            return str;
        }
    }

 text/plain

posted @ 2016-09-18 08:47  shiningrise  阅读(323)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css