机器码信息
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