BOOL WINAPI GlobalMemoryStatusEx(
__inout LPMEMORYSTATUSEX lpBuffer
);
示例代码:
void CTestDlg::GetMemoryInfo()
{
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx(&statex);
CString strInfo = "内存:\r\n";
CString strTemp = "";
// 内存使用率
strTemp.Format("There is %ld percent of memory in use.\r\n", statex.dwMemoryLoad);
strInfo += strTemp;
// 物理内存
strTemp.Format("There are %I64d total Kbytes of physical memory.\r\n", statex.ullTotalPhys/1024);
strInfo += strTemp;
// 可用物理内存
strTemp.Format("There are %I64d free Kbytes of physical memory.\r\n", statex.ullAvailPhys/1024);
strInfo += strTemp;
// 认可用量:总数
strTemp.Format("There are %I64d total Kbytes of paging file.\r\n", statex.ullTotalPageFile/1024);
strInfo += strTemp;
// 认可用量:未用
strTemp.Format("There are %I64d free Kbytes of paging file.\r\n", statex.ullAvailPageFile/1024);
strInfo += strTemp;
// 虚拟内存
strTemp.Format("There are %I64d total Kbytes of virtual memory.\r\n", statex.ullTotalVirtual/1024);
strInfo += strTemp;
// 可用虚拟内存
strTemp.Format("There are %I64d free Kbytes of virtual memory.\r\n", statex.ullAvailVirtual/1024);
strInfo += strTemp;
// ullAvailExtendedVirtual保留字段
strTemp.Format("There are %I64d free Kbytes of extended memory.\r\n", statex.ullAvailExtendedVirtual/1024);
strInfo += strTemp;
m_staticMemory.SetWindowText(strInfo);
}
运行结果: