mfc 获取物理内存和虚拟内存

void CGetSysInfo::GetMemoryInfo(CString &dwTotalPhys,CString &dwTotalVirtual)
{
	//   TODO:     Add   extra   initialization   here   
	MEMORYSTATUS   Mem;   
	//   get   the   memory   status   
	GlobalMemoryStatus(&Mem);   

	DWORD dwSize = (DWORD)Mem.dwTotalPhys/(1024*1024);   
	DWORD dwVirtSize = (DWORD)Mem.dwTotalVirtual/(1024*1024);  

	dwTotalPhys.Format(_T("物理内存:%ld MB"),dwSize);   
	dwTotalVirtual.Format(_T("虚拟内存:%ld MB"),dwVirtSize);  
}

你可能感兴趣的:(c++)