Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Detecting single/dual processors

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
Mcplanck
Asked:
Mcplanck
  • 3
1 Solution
 
jkrCommented:
Simply use 'GetSystemInfo()" - it fills in a 'SYSTEM_INFO' struct that has a member 'dwNumberOfProcessors'

0
 
jkrCommented:
BTW, here's a sample:

SYSTEM_INFO si;

GetSystemInfo ( &si);

printf ( "Number of Processors: %d", si.dwNumberOfProcessors);
0
 
jkrCommented:
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
 
McplanckAuthor Commented:
Doh!

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

0
 
AxterCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now