Archive: Get the number of CPUs or cores in a system


Get the number of CPUs or cores in a system
Hey it's me again! *breathes in the Winamp-forumy nostalgia*

So I'll keep it short and sweet. I broke out the ol' WinXP license to work on an installer for a paying client. I need to be able to detect the number of CPUs or cores in a system and can't seem to find out from Google how to do this with NSIS or any of its plugins. Anyone know of a plugin that can do this, or maybe someone with Windows API knowledge could hack something up in ten minutes? Thanks!

--Dan


http://nsis.sourceforge.net/CPUDesc_plug-in


You could also use the built-in registry functions to enumerate the keys and values under the following key (Windows only of course):

HKLM\HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor

This is the key that Windows populates during bootup so it reflects the actual number of processors/cores that Windows sees including changes in BOOT.INI/BCD to limit them.

There is one sub-key for each processor (0,1,2,3 etc) and the values are the description of processor characteristics including approximate clock speed and processor brand/model.

Duncan