C++获取内存大小和使用率
来源:互联网 发布:提升软件开发效率 编辑:程序博客网 时间:2024/05/12 06:06
// Sample output:// There is 51 percent of memory in use.// There are 2029968 total KB of physical memory.// There are 987388 free KB of physical memory.// There are 3884620 total KB of paging file.// There are 2799776 free KB of paging file.// There are 2097024 total KB of virtual memory.// There are 2084876 free KB of virtual memory.// There are 0 free KB of extended memory.#include <windows.h>#include <stdio.h>#include <tchar.h>// Use to convert bytes to KB#define DIV 1024// Specify the width of the field in which to print the numbers. // The asterisk in the format specifier "%*I64d" takes an integer // argument and uses it to pad and right justify the number.#define WIDTH 7void _tmain(){ MEMORYSTATUSEX statex; statex.dwLength = sizeof (statex); GlobalMemoryStatusEx (&statex); _tprintf (TEXT("There is %*ld percent of memory in use.\n"), WIDTH, statex.dwMemoryLoad); _tprintf (TEXT("There are %*I64d total KB of physical memory.\n"), WIDTH, statex.ullTotalPhys/DIV); _tprintf (TEXT("There are %*I64d free KB of physical memory.\n"), WIDTH, statex.ullAvailPhys/DIV); _tprintf (TEXT("There are %*I64d total KB of paging file.\n"), WIDTH, statex.ullTotalPageFile/DIV); _tprintf (TEXT("There are %*I64d free KB of paging file.\n"), WIDTH, statex.ullAvailPageFile/DIV); _tprintf (TEXT("There are %*I64d total KB of virtual memory.\n"), WIDTH, statex.ullTotalVirtual/DIV); _tprintf (TEXT("There are %*I64d free KB of virtual memory.\n"), WIDTH, statex.ullAvailVirtual/DIV); // Show the amount of extended memory available. _tprintf (TEXT("There are %*I64d free KB of extended memory.\n"), WIDTH, statex.ullAvailExtendedVirtual/DIV);}
参见MSDN:http://msdn.microsoft.com/en-us/library/windows/desktop/aa366589(v=vs.85).aspx
0 0
- C++获取内存大小和使用率
- 获取内存和CPU使用率
- linux下实现CPU使用率和内存使用率获取方法
- 获取CPU使用率的C代码
- C语言获取Windows总CPU使用率.
- Linux下C获取CPU使用率和内存和网络丢包率
- 获取内存大小
- 获取手机应用分配内存大小和状态
- Linux C程序 获取内存使用率和Cpu占有率,从Top 源码中裁剪移植
- 如何获取CPU的主频和使用率?
- linux下获取cpu和内存使用率
- LINUX下获取CPU和内存使用率
- golang调用c++dll 获取mac地址,用户名,内存大小
- Windows下用C语言获取系统的CPU利用率、内存使用率、硬盘使用率等
- Windows下用C语言获取系统的CPU利用率、内存使用率、硬盘使用率
- Windows下用C语言获取系统的CPU利用率、内存使用率、硬盘使用率等-转载
- Windows下用C语言获取系统的CPU利用率、内存使用率、硬盘使用率等
- linux c程序获取cpu使用率及内存使用情况
- 【C++】typedef与define的思考
- C# 6.0 (C# vNext) 新功能之:Expression Bodied Functions and Properties
- 大数据量索引分析
- ubuntu设置DNS
- MIPS CPU 50%的动态功耗
- C++获取内存大小和使用率
- FileZilla连接虚拟机ubuntu
- mysql之视图
- java线程状态
- 阿里云css分享 svn lock
- Oracle SQL Developer 连接 Mysql 等数据库
- GDT,LDT,GDTR,LDTR
- UNDO段头块格式深度解析
- 制作适用于openstack的Windows server 2008镜像