Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Detecting single/dual processors

Posted on 2001-06-08
5
Medium Priority
?
162 Views
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.

0
Comment
Question by:Mcplanck
  • 3
5 Comments
 
LVL 86

Accepted Solution

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

0
 
LVL 86

Expert Comment

by:jkr
ID: 6169443
BTW, here's a sample:

SYSTEM_INFO si;

GetSystemInfo ( &si);

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

Expert Comment

by:jkr
ID: 6169450
See also the API reference at http://msdn.microsoft.com/library/psdk/sysmgmt/sysinfo_3t67.htm and the article 'Getting Hardware Information' (http://msdn.microsoft.com/library/psdk/sysmgmt/sysinfo_9ige.htm):

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.
 
GetSystemInfo(&siSysInfo);
 
// Display the contents of the SYSTEM_INFO structure.
 
nSize = sprintf(tchBuffer,
    "OEM ID: %u\tNumber of Processors: %u",
    siSysInfo.dwOemId,
    siSysInfo.dwNumberOfProcessors);
TabbedTextOut(hdc, 25, 40, tchBuffer,
    nSize, 1, aTabs, 25);
 
nSize = sprintf(tchBuffer,
    "Page size: %u\tProcessor Type: %u",
    siSysInfo.dwPageSize,
    siSysInfo.dwProcessorType);
TabbedTextOut(hdc, 25, 60, tchBuffer,
    nSize, 1, aTabs, 25);
 
nSize = sprintf(tchBuffer,
    "Minimum app address: %lx\tMaximum app address: %lx",
    siSysInfo.lpMinimumApplicationAddress,
    siSysInfo.lpMaximumApplicationAddress);
TabbedTextOut(hdc, 25, 80, tchBuffer,
    nSize, 1, aTabs, 25);
 
nSize = sprintf(tchBuffer,
    "Active processor mask: %u",
    siSysInfo.dwActiveProcessorMask);
TextOut(hdc, 25, 100, tchBuffer, nSize);
0
 

Author Comment

by:Mcplanck
ID: 6170269
Doh!

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

0
 
LVL 30

Expert Comment

by:Axter
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. :-)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses
Course of the Month10 days, 21 hours left to enroll

885 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