windows API获取物理内存大于4G的方法
2015-08-03 09:49
295 查看
函数原型:
BOOL WINAPI GlobalMemoryStatusEx(_Inout_ LPMEMORYSTATUSEX lpBuffer);
调用dll Kernel32.dll
demo:
// 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 7 void _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); }参考: https://msdn.microsoft.com/en-us/library/aa366589(v=vs.85).aspx
相关文章推荐
- Android Manifest 用法
- 如何重装TCP/IP协议
- Windows 8 官方高清壁纸欣赏与下载
- 谁是桌面王者?Win PK Linux三大镇山之宝
- 对《大家都在点赞 Windows Terminal,我决定给你泼一盆冷水》一文的商榷
- Windows Clang开发环境备忘
- 从Windows系统下访问Linux分区相关软件
- 对《大家都在点赞 Windows Terminal,我决定给你泼一盆冷水》一文的商榷
- Visual Studio 2012 示例代码浏览器 - 数以千计的开发示例近在手边,唾手可得
- Visual Studio 2012 示例代码浏览器 - 数以千计的开发示例近在手边,唾手可得
- 微软镜像下载
- windows server域用户提升到本地更高权限组中的方法
- 使用命令修改注册表键值及权限
- 通过手机、电脑远程开关机,Windows和linux机手机,电脑相互控制
- Windows XP最新应用技巧大荟萃
- Windows 系统组策略应用全攻略(上)第1/2页
- VBS脚本写的Windows硬件检测工具分享
- Microsoft Windows Vista 简体中文企业版 MVL DVD IMG 32-bit(1.9GB)