The WMI class, ‘Win32_Processor’, will provide you with numerous bits of information about the CPUs in your machine. It is not possible however, to query whether hyperthreading is enabled, or otherwise query whether or not a processor is physical or logical.
Using the SocketDesignation property of the ‘Win32_Processor’ WMI class we can identify which socket each CPU is in. A physical CPU will report the true socket, and any logical CPU will report the same socket as your first CPU.
I have created a small C# console application to demonstrate detecting hyperthreading, by comparing the count of physical and logical CPUs.
You will need to add a reference to System.Management.
static void Main(string args)
List<string> Sockets=new List<string>();
//Create WMI Class
ManagementClass mc = new ManagementClass(“Win32_Processor”);
//Populate class with Processor objects
ManagementObjectCollection moc = mc.GetInstances();
//Iterate through logical processors
foreach (ManagementObject mo in moc)
string SocketDesignation = mo.Properties[“SocketDesignation”].Value.ToString();
//We will count the unique SocketDesignations to find
//the number of physical CPUs in the system.
PhysicalCPU = Sockets.Count;
Console.WriteLine(LogicalCPU + ” logical CPUs detected.”);
Console.WriteLine(PhysicalCPU + ” physical CPUs detected.”);
//Are there more logical than physical cpus?
//If so, obviously we are hyperthreading.
if (LogicalCPU > PhysicalCPU)
Console.WriteLine(“HyperThreading is enabled.”);
The sample code and available project are .net 2.0. If you want to use this in VS.net 2003, and .net 1.1, you will simply need to change our the List