标签:
using System; using System.Runtime.InteropServices; using System.Management; namespace Hardware { /// summary /// Hardware_Mac 的摘要说明。 /// /summary public class HardwareInfo { //取机器名 public string GetHostName() { return System.Net.Dns.GetHostName(); } //取CPU编号 public String GetCpuID() { try { ManagementClass mc = new ManagementClass(Win32_Processor); ManagementObjectCollection moc = mc.GetInstances(); String strCpuID = null; foreach (ManagementObject mo in moc) { strCpuID = mo.Properties[ProcessorId].Value.ToString(); break; } return strCpuID; } catch { return ; } }//end method //取第一块硬盘编号 public String GetHardDiskID() { try { ManagementObjectSearcher searcher = new ManagementObjectSearcher(SELECT * FROM Win32_PhysicalMedia); String strHardDiskID = null; foreach (ManagementObject mo in searcher.Get()) { strHardDiskID = mo[SerialNumber].ToString().Trim(); break; } return strHardDiskID;
以上就是获取计算机信息的类,在VS中建一个类,然后生成DLL就可以在平台中使用了
原文地址:http://bbs.delit.cn/thread-584-1-1.html
转载请注明出处:
撰写人:度量科技www.delit.cn
标签:
原文地址:http://www.cnblogs.com/dlsoft/p/5112700.html