devxlogo

Determine type and number of CPUs

Determine type and number of CPUs

There is no method call that directly retuns information about the number and type of installed CPU(s). However, this information is stored in a few environment variables, so it’s just a matter of extracting it with the Environment.GetEnvironmentVariable method:

' this code is meant to run under Windows NT, 2000, or XPConsole.WriteLine("Number of CPUs: {0}", Environment.GetEnvironmentVariable _    ("NUMBER_OF_PROCESSORS"))Console.WriteLine("CPU Architecture: {0}", Environment.GetEnvironmentVariable _    ("PROCESSOR_ARCHITECTURE"))Console.WriteLine("CPU Identifier: {0}", Environment.GetEnvironmentVariable _    ("PROCESSOR_IDENTIFIER"))Console.WriteLine("CPU Level: {0}", Environment.GetEnvironmentVariable _    ("PROCESSOR_LEVEL"))Console.WriteLine("CPU Revision: {0}", Environment.GetEnvironmentVariable _    ("PROCESSOR_REVISION"))

This is a sample output produced by the previous code:

Number of CPUs: 1CPU Architecture: x86CPU Identifier: x86 Family 6 Model 6 Stepping 2, AuthenticAMDCPU Level: 6CPU Revision: 0602

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist