Last active
January 16, 2016 06:31
-
-
Save maldevel/a4e3f9c8e882abfe81ac to your computer and use it in GitHub Desktop.
Retrieve Processors Information
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Management; | |
namespace coreinfo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
PrintCoreInfo(); | |
} | |
static void PrintCoreInfo() | |
{ | |
try | |
{ | |
string cpuName = string.Empty; | |
string query = "SELECT * FROM Win32_Processor"; | |
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(query)) | |
{ | |
foreach (ManagementObject mObject in searcher.Get()) | |
{ | |
Console.WriteLine("Physical CPU: " + mObject["Name"].ToString()); | |
Console.WriteLine("Logical CPU(s): " + mObject["NumberOfLogicalProcessors"].ToString()); | |
Console.WriteLine("Core(s): " + mObject["NumberOfCores"].ToString()); | |
} | |
} | |
} | |
catch | |
{ | |
Console.WriteLine("Retrieving core information failed!"); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment