#include <iostream>
#include <windows.h>
#include <stdio.h>
#include <tchar.h>
#include "st.h"

#define DIV (1024.0*1024.0*1024.0)

#ifdef NO_MAIN
extern "C" {
extern int mem_main();
}
int mem_main()
#else
int main()
#endif
{
  MEMORYSTATUSEX statex;

  statex.dwLength = sizeof (statex);

  GlobalMemoryStatusEx (&statex);

  cout << (long)statex.dwMemoryLoad << " percent of memory in use" << endl;
  cout << ((double)statex.ullTotalPhys/DIV) << " GB of physical memory" << endl;
  cout << ((double)statex.ullAvailPhys/DIV) << " GB free physical memory" << endl;
  cout << ((double)statex.ullTotalPageFile/DIV) << " GB of paging file" << endl;
  cout << ((double)statex.ullAvailPageFile/DIV) << " GB free of paging file" << endl;
  cout << ((double)statex.ullTotalVirtual/DIV) << " GB of virtual memory" << endl;
  cout << ((double)statex.ullAvailVirtual/DIV) << " GB free of virtual memory" << endl;
  cout << ((double)statex.ullAvailExtendedVirtual/DIV) << " free GB of extended memory" << endl;

  return 0;
}
