Console.WriteLine("---------------- Processor ------------------");
try
{
ManagementClass managementClass = new ManagementClass("Win32_Processor");
ManagementObjectCollection managementObj = managementClass.GetInstances();
foreach(ManagementObject mo in managementObj)
{
Console.WriteLine("AddressWidth:\t{0}", mo["AddressWidth"]);
// Architecture
ushort arch = (ushort)mo["Architecture"];
string[] architecture = {"x86", "MIPS", "Alpha", "PowerPC", "Unknown"};
if (arch <= 3)
Console.WriteLine("Architecture:\t {0}", architecture[arch]);
else
Console.WriteLine("Architecture:\t Unknown");
Console.WriteLine("Architecture:\t {0}", architecture[arch]);
// Availability
ushort avail = (ushort)mo["Availability"];
string[] availability = {
"-", "Other", "Unknown", "Running/Full Power", "Warning", "In Test",
"Not Applicable", "Power Off", "Off Line", "Off Duty", "Degraded",
"Not Installed", "Install Error", "Power Save - Unknown", "Power Save - Low Power Mode", "Power Save - Standby",
"Power Cycle", "Power Save - Warning", "Paused", "Not Ready", "Not Configured",
"Quiesced"
};
if (avail <= 21)
Console.WriteLine("Availability:\t {0}", availability[avail]);
else
Console.WriteLine("Availability:\t Unknown");
// Caption
Console.WriteLine("Caption :\t{0}", mo["Caption"]);
Console.WriteLine("ConfigManagerErrorCode:\t{0}", mo["ConfigManagerErrorCode"]);
Console.WriteLine("ConfigManagerUserConfig:\t{0}", mo["ConfigManagerUserConfig"]);
// CpuStatus
ushort cpuStat = (ushort)mo["CpuStatus"];
string[] cpuStatus = {
"-", "Unknown", "CPU Enabled", "CPU Disabled by User via BIOS Setup", "CPU Disabled By BIOS (POST Error)", "CPU is Idle",
"Reserved", "Reserved", "Other",
};
if (cpuStat <= 8)
Console.WriteLine("CpuStatus:\t {0}", cpuStatus[cpuStat]);
else
Console.WriteLine("CpuStatus:\t Unknown");
// CreationClassName
Console.WriteLine("CreationClassName:\t{0}", mo["CreationClassName"]);
Console.WriteLine("CurrentClockSpeed:\t{0} MHz", mo["CurrentClockSpeed"]);
// CurrentVoltage
ushort cv = (ushort)mo["CurrentVoltage"];
Console.WriteLine("CurrentVoltage:\t{0} V", (float)cv/10F);
Console.WriteLine("DataWidth:\t{0} bit", mo["DataWidth"]);
Console.WriteLine("Description:\t{0}", mo["Description"]);
Console.WriteLine("DeviceID:\t{0}", mo["DeviceID"]);
Console.WriteLine("ErrorCleared:\t{0}", mo["ErrorCleared"]);
Console.WriteLine("ErrorDescription:\t{0}", mo["ErrorDescription"]);
Console.WriteLine("ExtClock:\t{0} MHz", mo["ExtClock"]);
// Family
string[] family = {
"Other", "Unknown", "8086", "80286", "80386", "80486", // 0-
"8087", "80287", "80387", "80487", "Pentium Family", // 6-
"Pentium Pro", "Pentium II", "Pentium MMX", "Celeron", "Pentium II Xeon", // 11-
"Pentium III", "M1 Family", "M2 Family", "K5 Family", "K6 Family", // 16-
"K6-2", "K6-III", "Athlon", "Power PC Family", "Power PC 601", // 21-
"Power PC 603", "Power PC 603+", "Power PC 604", "Alpha Family", "MIPS Family", // 26-
"SPARC Family", "68040", "68xxx Family", "68000", "68010", // 31-
"68020", "68030", "Hobbit Family", "Weitek", "PA-RISC Family", // 36-
"V30 Family", "Pentium III Xeon", "AS400 Family", "IBM390 Family", "i860", // 41-
"i960", "SH-3", "SH-4", "ARM", "StrongARM", // 46-
"6x86", "MediaGX", "MII", "WinChip" // 54-
};
ushort f = (ushort)mo["Family"];
if (f <= 54)
Console.WriteLine("Family:\t {0}, {1}", f, family[f]);
else
Console.WriteLine("Family:\t Unknown");
// InstallDate
Console.WriteLine("InstallDate:\t{0}", mo["InstallDate"]);
// L2CacheSize
Console.WriteLine("L2CacheSize:\t{0}", mo["L2CacheSize"]);
Console.WriteLine("L2CacheSpeed:\t{0}", mo["L2CacheSpeed"]);
Console.WriteLine("LastErrorCode:\t{0}", mo["LastErrorCode"]);
Console.WriteLine("Level:\t{0}", mo["Level"]);
Console.WriteLine("LoadPercentage:\t{0}", mo["LoadPercentage"]);
// Manufacturer
Console.WriteLine("Manufacturer:\t{0}", mo["Manufacturer"]);
Console.WriteLine("MaxClockSpeed:\t{0}", mo["MaxClockSpeed"]);
// Name
Console.WriteLine("Name:\t{0}", mo["Name"]);
// OtherFamilyDescription
Console.WriteLine("OtherFamilyDescription:\t{0}", mo["OtherFamilyDescription"]);
// PNPDeviceID
Console.WriteLine("PNPDeviceID:\t{0}", mo["PNPDeviceID"]);
// PowerManagementCapabilities
ushort [] pmArray = (ushort[])mo["PowerManagementCapabilities"];
string[] pms = {
"Other", "Not Supported", "Disabled", "Enabled", "Power Saving Modes Entered Automatically", "Power State Settable",
"Power Cycling Supported", "Timed Power On Supported"};
if (pmArray != null)
foreach(ushort p in pmArray)
{
if (p <= 7)
Console.WriteLine("PowerManagementCapabilities:\t {0}", pms[p]);
else
Console.WriteLine("PowerManagementCapabilities:\t Unknown");
}
// PowerManagementSupported
Console.WriteLine("PowerManagementSupported:\t{0}", mo["PowerManagementSupported"].ToString());
Console.WriteLine("ProcessorId:\t{0}", mo["ProcessorId"]);
// ProcessorType
ushort pType = (ushort)mo["ProcessorType"];
string[] proType = {
"-", "Other", "Unknown", "Central Processor", "Math Processor", "DSP Processor",
"Video Processor"};
if (pType <= 6)
Console.WriteLine("ProcessorType:\t {0}", proType[pType]);
else
Console.WriteLine("ProcessorType:\t Unknown");
// Revision
Console.WriteLine("Revision:\t{0}", mo["Revision"].ToString());
Console.WriteLine("Role:\t{0}", mo["Role"]);
// SocketDesignation
Console.WriteLine("SocketDesignation:\t{0}", mo["SocketDesignation"]);
Console.WriteLine("Status:\t{0}", mo["Status"]);
Console.WriteLine("StatusInfo:\t{0}", mo["StatusInfo"].ToString());
Console.WriteLine("Stepping:\t{0}", mo["Stepping"]);
Console.WriteLine("SystemCreationClassName:\t{0}", mo["SystemCreationClassName"]);
Console.WriteLine("SystemName:\t{0}", mo["SystemName"]);
// UniqueId
Console.WriteLine("UniqueId:\t{0}", mo["UniqueId"]);
Console.WriteLine("UpgradeMethod:\t{0}", mo["UpgradeMethod"].ToString());
// Version
Console.WriteLine("Version:\t{0}", mo["Version"]);
Console.WriteLine("VoltageCaps:\t{0}", mo["VoltageCaps"]);
Console.WriteLine("---------------- End of Processor ------------------");
}
}
catch(Exception exc)
{
Console.WriteLine(exc.Message);
}
|