Detecting single/dual processors

Posted on 2001-06-08
Last Modified: 2010-04-02
Visual C++ 6.0, Windows NT 4.0 and Windows 2000

Does anybody know how to detect for how many processors are in the system?

This should be easy, but I can't seem to find it anywhere.

Question by:Mcplanck
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 86

Accepted Solution

jkr earned 50 total points
ID: 6169438
Simply use 'GetSystemInfo()" - it fills in a 'SYSTEM_INFO' struct that has a member 'dwNumberOfProcessors'

LVL 86

Expert Comment

ID: 6169443
BTW, here's a sample:


GetSystemInfo ( &si);

printf ( "Number of Processors: %d", si.dwNumberOfProcessors);
LVL 86

Expert Comment

ID: 6169450
See also the API reference at and the article 'Getting Hardware Information' (

SYSTEM_INFO siSysInfo;   // struct. for hardware information
int aTabs[1] = {260};    // tab stop for TabbedTextOut
TCHAR tchBuffer[BUFFER]; // buffer for expanded string
int nSize;               // size of string
// Display the "hardware information" header.
nSize = sprintf(tchBuffer,
    "Hardware information:");
TextOut(hdc, 15, 20, tchBuffer, nSize);
// Copy the hardware information to the SYSTEM_INFO structure.
// Display the contents of the SYSTEM_INFO structure.
nSize = sprintf(tchBuffer,
    "OEM ID: %u\tNumber of Processors: %u",
TabbedTextOut(hdc, 25, 40, tchBuffer,
    nSize, 1, aTabs, 25);
nSize = sprintf(tchBuffer,
    "Page size: %u\tProcessor Type: %u",
TabbedTextOut(hdc, 25, 60, tchBuffer,
    nSize, 1, aTabs, 25);
nSize = sprintf(tchBuffer,
    "Minimum app address: %lx\tMaximum app address: %lx",
TabbedTextOut(hdc, 25, 80, tchBuffer,
    nSize, 1, aTabs, 25);
nSize = sprintf(tchBuffer,
    "Active processor mask: %u",
TextOut(hdc, 25, 100, tchBuffer, nSize);

Author Comment

ID: 6170269

Thanks dude, I was looking under OSInfo, not System info!

LVL 30

Expert Comment

ID: 6170348
MS doesn't make it easy for anyone to look up stuff.

You think they would have cross reference it.  But that would make things to easy for us programmers. And we can't have that. :-)

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question