c++memorysystem

How can I find out how much memory is physically installed in Windows?


I need to log information about how much RAM the user has. My first approach was to use GlobalMemoryStatusEx but that only gives me how much memory is available to windows, not how much is installed. I found this function GetPhysicallyInstalledSystemMemory but its only Vista and later. I need this to work on XP. Is there a fairly simple way of querying the SMBIOS information that GetPhysicallyInstalledSystemMemory was using or is there a registry value somewhere that I can find this out.


Solution

  • EDIT: I'd use steelbytes' answer, but if you can't use WMI For some reason, you can do this:

    I don't believe Windows versions prior to Vista track this information -- you'd have to do some system specific BIOS or Motherboard enumeration to find the true value prior to Vista. Your best bet is to call the new API, GetPhysicallyInstalledSystemMemory, and fail over to GlobalMemoryStatusEx for XP systems.