#include <Windows.h>
#include <sstream>
// Use to convert bytes to KB
#define KB 1024
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
/*
typedef struct _MEMORYSTATUSEX {
DWORD dwLength;
DWORD dwMemoryLoad;
DWORDLONG ullTotalPhys;
DWORDLONG ullAvailPhys;
DWORDLONG ullTotalPageFile;
DWORDLONG ullAvailPageFile;
DWORDLONG ullTotalVirtual;
DWORDLONG ullAvailVirtual;
DWORDLONG ullAvailExtendedVirtual;
} MEMORYSTATUSEX, *LPMEMORYSTATUSEX;
*/
MEMORYSTATUSEX memInfo;
memInfo.dwLength = sizeof(MEMORYSTATUSEX);
// Retrieves information about the system's current physical and virtual memory usage
GlobalMemoryStatusEx(&memInfo);
DWORDLONG totalPhysicalMemory_RAM = memInfo.ullTotalPhys / (KB * KB * KB);
std::ostringstream oss;
oss << totalPhysicalMemory_RAM << " GB";
std::string s = oss.str();
MessageBoxA(0, s.c_str(), "Total Virtual Memory", MB_OK);
return 0;
}
/*
run:
31 GB
*/