Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
How can I find out in Win64 how many...

How can I find out in Win64 how many processor cores there are in the system?

Mar 11 2012

To get information about the number of processor cores in the system, you may use the Windows environment variable NUMBER_OF_PROCESSORS. Below is a fragment of C++ code where the WinAPI GetEnvironmentVariable method is used to extract and display the contents of this environment variable.

#include <windows.h>
#include <tchar.h>
#include <stdio.h>

#define VARNAME TEXT("NUMBER_OF_PROCESSORS")
#define BUFSIZE 4096

int main()
{
  TCHAR buf[BUFSIZE];
  DWORD dwRet = GetEnvironmentVariable(VARNAME, buf, BUFSIZE);
  if (dwRet > 0 && dwRet < BUFSIZE)
    _tprintf(_T("Number of processors: %s\n"), buf);

  return 0;
}

References

Subscribe to the newsletter
Want to receive a monthly digest of the most interesting articles and news? Subscribe!
Popular related articles


Comments (0)

Next comments next comments
close comment form