项目结束了,公司要求做一个授权码。于是,我就获取了部署服务器硬件的一些信息。 public string getCpuInfo() //读取CPU信息 { ManagementClass mobj = new ManagementClass("Win32_Processor"); ManagementObjectCollection moc = mobj.GetInstances(); foreach (ManagementObject mo in moc) { return mo.Properties["ProcessorId"].Value.ToString(); } return ""; } public string getHddInfo() //读取硬盘信息 { ManagementClass mobj = new ManagementClass("Win32_PhysicalMedia"); ManagementObjectCollection moc = mobj.GetInstances(); foreach (ManagementObject mo in moc) { return mo.Properties["SerialNumber"].Value.ToString(); } return ""; }