windows api 获取内存信息函数以及示例
2009-08-13 23:22
330 查看
获取内存的信息:
#include "stdafx.h"
#include <windows.h>
#include "stdio.h"
// Use to change the divisor from Kb to Mb.
#define DIV 1024
// #define DIV 1
char *divisor = "K";
#define WIDTH 7
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 %sbytes of physical memory./n",
WIDTH, stat.dwTotalPhys/DIV, divisor);
printf ("There are %*ld free %sbytes of physical memory./n",
WIDTH, stat.dwAvailPhys/DIV, divisor);
printf ("There are %*ld total %sbytes of paging file./n",
WIDTH, stat.dwTotalPageFile/DIV, divisor);
printf ("There are %*ld free %sbytes of paging file./n",
WIDTH, stat.dwAvailPageFile/DIV, divisor);
printf ("There are %*lx total %sbytes of virtual memory./n",
WIDTH, stat.dwTotalVirtual/DIV, divisor);
printf ("There are %*lx free %sbytes of virtual memory./n",
WIDTH, stat.dwAvailVirtual/DIV, divisor);
}
#include "stdafx.h"
#include <windows.h>
#include "stdio.h"
// Use to change the divisor from Kb to Mb.
#define DIV 1024
// #define DIV 1
char *divisor = "K";
#define WIDTH 7
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 %sbytes of physical memory./n",
WIDTH, stat.dwTotalPhys/DIV, divisor);
printf ("There are %*ld free %sbytes of physical memory./n",
WIDTH, stat.dwAvailPhys/DIV, divisor);
printf ("There are %*ld total %sbytes of paging file./n",
WIDTH, stat.dwTotalPageFile/DIV, divisor);
printf ("There are %*ld free %sbytes of paging file./n",
WIDTH, stat.dwAvailPageFile/DIV, divisor);
printf ("There are %*lx total %sbytes of virtual memory./n",
WIDTH, stat.dwTotalVirtual/DIV, divisor);
printf ("There are %*lx free %sbytes of virtual memory./n",
WIDTH, stat.dwAvailVirtual/DIV, divisor);
}
相关文章推荐
- Android获取系统储存以及内存信息的方法(一)
- Android小功能 -- 获取系统内存信息以及进程信息
- SqlServer如何通过SQL语句获取处理器(CPU)、内存(Memory)、磁盘(Disk)以及操作系统相关信息
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一) .
- Delphi 获取内存及CPU信息的函数
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- WordPress中用于获取文章信息以及分类链接的函数用法
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一
- SqlServer如何通过SQL语句获取处理器(CPU)、内存(Memory)、磁盘(Disk)以及操作系统相关信息
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- c#不使用windows api函数打开我的电脑和获取电脑驱动器信息
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android中获取系统内存信息以及进程信息-----ActivityManager的使用(一)
- Android获取系统储存以及内存信息(一)