using System.Management;
public class IdentificationClass
{
public string? CPU { get; set; }
public string? ComputerName { get; set; }
public string? MainBoard { get; set; }
public string? HardDisk { get; set; }
}
public class Computer
{
private const string QueryString = "Select SerialNumber From Win32_BaseBoard";
private const string CPUQueryString = "Select ProcessorId From Win32_processor";
public static IdentificationClass GetComputerInfo()
{
// Name
IdentificationClass identification = new IdentificationClass();
identification.ComputerName = Environment.MachineName;
// 硬盘
ManagementObject obp = new ManagementObject(@"Win32_LogicalDisk.deviceid=""c:""");
obp.Get();
identification.HardDisk = obp["VolumeSerialNumber"].ToString();
// 主板
ManagementObjectSea