How to get number of cores in Win32? How to get number of cores in Win32? multithreading multithreading

How to get number of cores in Win32?


You can call the GetSystemInfo WinAPI function; it returns a SYSTEM_INFO struct, which has the number of processors (which is the number of cores on a system with multiple core CPUs).


You can read NUMBER_OF_PROCESSORS environment variable.


Even though the question deals with .NET and yours with C, the basic responses should help:

Detecting the number of processors