1 public class GetUserInfo 2 { 3 public static string GetCPU() 4 { 5 string cpuInfo = "";//cpu序列号 6 ManagementClass cimobject = new ManagementClass("Win32_Processor"); 7 ManagementObjectCollection moc = cimobject.GetInstances(); 8 foreach (ManagementObject mo in moc) 9 { 10 cpuInfo = mo.Properties["ProcessorId"].Value.ToString(); 11 // Response.Write ("cpu序列号:"+cpuInfo.ToString ()); 12 } 13 return cpuInfo; 14 } 15 16 public static string GetHardDisk() 17 { 18 string HDid = string.Empty; 19 ManagementClass cimobject1 = new ManagementClass("Win32_DiskDrive"); 20 ManagementObjectCollection moc1 = cimobject1.GetInstances(); 21 foreach (ManagementObject mo in moc1) 22 { 23 HDid = (string)mo.Properties["Model"].Value; 24 //Response.Write ("硬盘序列号:"+HDid.ToString ()); 25 26 } 27 return HDid; 28 } 29 30 31 public static string GetRealIp() 32 { 33 string ip = ""; 34 try 35 { 36 HttpRequest request = HttpContext.Current.Request; 37 38 if (request.ServerVariables["http_VIA"] != null) 39 { 40 ip = request.ServerVariables["http_X_FORWARDED_FOR"].ToString().Split(',')[0].Trim(); 41 } 42 else 43 { 44 ip = request.UserHostAddress; 45 } 46 } 47 catch (Exception e) 48 { 49 throw e; 50 } 51 52 return ip; 53 } 54 }
这个只是获取系统信息的一部分代码,获取都差不多的。
要不要别人帮你把工资给领了