// GetSystemInfo.cpp : 定義控制台應用程序的入口點。 // #include "stdafx.h" #include <iostream> #include <windows.h> #include <iomanip> using namespace std; int main() { SYSTEM_INFO systemInfo; GetSystemInfo(&systemInfo); cout << setw(20) << "處理器掩碼: " << systemInfo.dwActiveProcessorMask << endl << setw(20) << "處理器個數: " << systemInfo.dwNumberOfProcessors << endl << setw(20) << "處理器分頁大小: " << systemInfo.dwPageSize << endl << setw(20) << "處理器類型: " << systemInfo.dwProcessorType << endl << setw(20) << "最大尋址單元: " << systemInfo.lpMaximumApplicationAddress << endl << setw(20) << "最小尋址單元: " << systemInfo.lpMinimumApplicationAddress << endl << setw(20) << "處理器等級: " << systemInfo.wProcessorLevel << endl << setw(20) << "處理器版本: " << systemInfo.wProcessorRevision << endl; return 0; }
// GlobalMemoryStatus.cpp : 定義控制台應用程序的入口點。 // #include "stdafx.h" #include <Windows.h> #include <iostream> using namespace std; int main() { MEMORYSTATUS ms; //記錄內容空間信息的結構體變量 GlobalMemoryStatus(&ms);//調用GlobalMemoryStatus()函數獲取內存信息 cout << "total physical mem:" << (float)ms.dwTotalPhys / 1024 / 1024 << "MB" << endl; //總的物理內存大小 cout << "used physical mem:" << (float)(ms.dwTotalPhys - ms.dwAvailPhys) / 1024 / 1024 << "MB" << endl; //已用物理內存大小 cout << "avilible physical mem:" << (float)ms.dwAvailPhys / 1024 / 1024 << "MB" << endl; //可用物理內存大小 cout << endl; cout << "total Virtual mem:" << (float)ms.dwTotalVirtual / 1024 / 1024 << "MB" << endl; //總的虛擬內存大小 cout << "used Virtual mem:" << (float)(ms.dwTotalVirtual - ms.dwAvailVirtual) / 1024 / 1024 << "MB" << endl; //已用虛擬內存大小 cout << "avilible Virtual mem:" << (float)ms.dwAvailVirtual / 1024 / 1024 << "MB" << endl; //可用虛擬內存大小 return 0; }