void CGetInfoDlg::GetMemoryInfo()
{
// TODO: 在此处添加实现代码.
m_Memory.dwLength = sizeof(m_Memory);
GlobalMemoryStatusEx(&m_Memory);
CString str;
str.Format(_T("总的物理内存:%lldKB"), m_Memory.ullTotalPhys / 1024);
m_totalPhyMemory.SetWindowTextW(str);
str.Format(_T("可用物理内存:%lldKB"), m_Memory.ullAvailPhys / 1024);
m_freePhyMemory.SetWindowTextW(str);
str.Format(_T("总的虚拟内存:%lldKB"), m_Memory.ullTotalVirtual / 1024);
m_totalVirtualMemory.SetWindowTextW(str);
str.Format(_T("可用虚拟内存:%lldKB"), m_Memory.ullAvailVirtual / 1024);
m_freeVirtualMemory.SetWindowTextW(str);
}
此博客展示了使用MFC和C++编写的获取内存信息的代码。通过`GlobalMemoryStatusEx`函数获取内存状态,包括总的和可用的物理内存、虚拟内存,并将这些信息显示在对话框控件中。
847

被折叠的 条评论
为什么被折叠?



