For Windows 7 and 2008 servers, the GetActiveProcessorGroupCount function exists . But you have a server 2003, so this is not an option.
In C ++, this requires writing WMI consumer code, which is a clumsy and boring (D) COM material.
One nice solution would be to run the systeminfo
command and analyze the output, but be careful as the header of the output column is localized in the system locale.
EDIT
It just found a much nicer solution that uses the command line interface for WMI.
Run the following command and parse, there is one line for each socket
> wmic.exe cpu get AddressWidth Architecture Availability Caption ConfigManagerErrorCode ConfigManagerUserConfig CpuStatus CreationClassName CurrentClockSpeed CurrentVoltage DataWidth Description DeviceID ErrorCleared ErrorDescription ExtClock Family InstallDate L2CacheSize L2CacheSpeed L3CacheSize L3CacheSpeed LastErrorCode Level LoadPercentage Manufacturer MaxClockSpeed Name NumberOfCores NumberOfLogicalProcessors OtherFamilyDescription PNPDeviceID PowerManagementCapabilities PowerManagementSupported ProcessorId ProcessorType Revision Role SocketDesignation Status StatusInfo Stepping SystemCreationClassName SystemName UniqueId UpgradeMethod Version VoltageCaps 64 9 3 Intel64 Family 6 Model 23 Stepping 6 1 Win32_Processor 2532 33 64 Intel64 Family 6 Model 23 Stepping 6 CPU0 421 2 0 0 6 1 GenuineIntel 2532 Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz 2 2 FALSE BFEBFBFF00010676 3 5894 CPU CPU Socket #0 OK 3 Win32_ComputerSystem CHBROSSO-WIN7VM 1 2
CurrentClockSpeed CurrentVoltage DataWidth Description DeviceID ErrorCleared ErrorDescription ExtClock Family InstallDate L2CacheSize L2CacheSpeed L3CacheSize L3CacheSpeed LastErrorCode Level LoadPercentage Manufacturer MaxClockSpeed Name NumberOfCores NumberOfLogicalProcessors OtherFamilyDescription PNPDeviceID PowerManagementCapabilities PowerManagementSupported ProcessorId ProcessorType Revision Role SocketDesignation Status StatusInfo Stepping SystemCreationClassName SystemName UniqueId UpgradeMethod Version VoltageCaps > wmic.exe cpu get AddressWidth Architecture Availability Caption ConfigManagerErrorCode ConfigManagerUserConfig CpuStatus CreationClassName CurrentClockSpeed CurrentVoltage DataWidth Description DeviceID ErrorCleared ErrorDescription ExtClock Family InstallDate L2CacheSize L2CacheSpeed L3CacheSize L3CacheSpeed LastErrorCode Level LoadPercentage Manufacturer MaxClockSpeed Name NumberOfCores NumberOfLogicalProcessors OtherFamilyDescription PNPDeviceID PowerManagementCapabilities PowerManagementSupported ProcessorId ProcessorType Revision Role SocketDesignation Status StatusInfo Stepping SystemCreationClassName SystemName UniqueId UpgradeMethod Version VoltageCaps 64 9 3 Intel64 Family 6 Model 23 Stepping 6 1 Win32_Processor 2532 33 64 Intel64 Family 6 Model 23 Stepping 6 CPU0 421 2 0 0 6 1 GenuineIntel 2532 Intel(R) Core(TM)2 Duo CPU T9400 @ 2.53GHz 2 2 FALSE BFEBFBFF00010676 3 5894 CPU CPU Socket #0 OK 3 Win32_ComputerSystem CHBROSSO-WIN7VM 1 2
Performing exe and parsing in C ++ should be easy. You can also use the POCO library or Boost.Process to get cleaner code.
(this is unverified code)
//get wmic program output FILE* pipe = _popen("wmic.exe cpu get", "r"); if (!pipe) throw std::exception("error"); char buffer[128]; std::string output; while(!feof(pipe)) { if(fgets(buffer, 128, pipe) != NULL) output += buffer; } _pclose(pipe); //split lines to a vector<string> std::stringstream oss(output); std::vector<std::string> processor_description; std::string buffer; while (std::getline(oss, buffer)) processor_description.push_back(buffer); //processor_description has n+1 elements, n being nb of sockets, +1 is the header of columns
source share