Get Total Amount of RAM in System using C++

GlobalMemoryStatusEx function (Win32 API)

#include <iostream>
#include <windows.h>

int main()
{
    MEMORYSTATUSEX statusEx;
    statusEx.dwLength = sizeof(statusEx);

    GlobalMemoryStatusEx(&statusEx);
    unsigned long long totalMem = statusEx.ullTotalPhys;

    std::cout << totalMem;

    return 0;
}

Leave a Comment

Cancel reply

Your email address will not be published.