#include
#include
using namespace std;
void GetProcessorInfo();
void GetMemInfo();
int main(int argc, char* argv[])
{
GetProcessorInfo();
GetMemInfo();
GetDeviceInfo();
return 0;
}
void GetProcessorInfo()
{
SYSTEM_INFO sysInfo;
string processorType;
GetSystemInfo (&sysInfo);
if (sysInfo.dwProcessorType == PROCESSOR_INTEL_386)
{
processorType = "Intel 386";
}
else if (sysInfo.dwProcessorType == PROCESSOR_INTEL_486)
{
processorType = "Intel 486";
}
else if (sysInfo.dwProcessorType == PROCESSOR_INTEL_PENTIUM)
{
processorType = "Intel Pentium";
}
else if (sysInfo.dwProcessorType == PROCESSOR_MIPS_R4000)
{
processorType = "MIPS";
}
else if (sysInfo.dwProcessorType == PROCESSOR_ALPHA_21064)
{
processorType = "Alpha";
}
else {
processorType = "Unknown";
}
cout << processorType << " " << sysInfo.dwNumberOfProcessors << "核" << endl;
}
void GetMemInfo()
{
MEMORYSTATUS status;
GlobalMemoryStatus(&status);
cout << "内存使用率:" << status.dwMemoryLoad << "%" << endl;
cout << "总物理内存大小:" << status.dwTotalPhys / (1024*1024) << "M" << endl;
cout << "可用物理内存大小:" << status.dwAvailPhys / (1024*1024) << "M" << endl;
}
所谓API就是MFC中的一些函数,按照函数声明直接调用。