c++ - 如何在 Visual C++ 中获取 RAM 总量?
问题描述
我需要在 Windows 窗体加载时获得 RAM 总量。我试图这样得到它:
#include <windows.h>
Form1(void)
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
unsigned long long RAM_GB = statex.ullTotalPhys / 1024ll / 1024ll / 1024ll;
}
这里我得到 RAM_GB = 23,但我的电脑有 32GB 的 RAM。这个功能是如何工作的?为什么它显示的内存比我的计算机实际内存少?