#include <windows.h>
void getMemoryUsage(unsigned long *total,
unsigned long *avail,
float *usage,
unsigned long *virt_total,
unsigned long *virt_avail)
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof(statex);
GlobalMemoryStatusEx(&statex);
if (total != NULL) // mémoire physique totale
*total = (unsigned long)(statex.ullTotalPhys / 1024);
if (avail != NULL) // mémoire physique disponible
*avail = (unsigned long)(statex.ullAvailPhys / 1024);
if (usage != NULL) // pourcentage d'utilisation de la mémoire physique
*usage = (float)(statex.dwMemoryLoad);
if (virt_total != NULL) // mémoire virtuelle totale
*virt_total = (unsigned long)(statex.ullTotalVirtual / 1024);
if (virt_avail != NULL) // mémoire virtuelle disponible
*virt_avail = (unsigned long)(statex.ullAvailVirtual / 1024);
}