C编程查看系统内存

1647阅读 0评论2009-12-12 red_eyed_hare
分类:WINDOWS

#include
#include
#define DIV 1048576
 
void main(int argc, char *argv[])
{
  MEMORYSTATUS stat;
  GlobalMemoryStatus (&stat);
  printf ("The MemoryStatus structure is %ld bytes long.\n",
          stat.dwLength);
  printf ("It should be %d.\n", sizeof (stat));
  printf ("%ld percent of memory is in use.\n",
          stat.dwMemoryLoad);
  printf ("There are %ld total M of physical memory.\n",
          stat.dwTotalPhys/DIV);
  printf ("There are %ld free M of physical memory.\n",
          stat.dwAvailPhys/DIV);
  printf ("There are %ld total M of paging file.\n",
          stat.dwTotalPageFile/DIV);
  printf ("There are %ld free M of paging file.\n",
          stat.dwAvailPageFile/DIV);
  printf ("There are %ld total M of virtual memory.\n",
          stat.dwTotalVirtual/DIV);
  printf ("There are %ld free M of virtual memory.\n",
          stat.dwAvailVirtual/DIV);
}
上一篇:文件数据匹配(KMP)
下一篇:虚拟机网卡激活