//起因:在某些机器上无法使用GlobalMemoryStatusEx和GlobalMemoryStatus获取到正确的总内存大小 //可使用GetPhysicallyInstalledSystemMemory获取到。 //该函数只支持windows vista/7/8/server 2008/ server 2012 std::string s; s.resize(64); ULONGLONG *ptr_mem = new ULONGLONG; if (GetPhysicallyInstalledSystemMemory(ptr_mem)) { sprintf_s(&s[0], s.length(), "TotalMem : %d", *ptr_mem / 1024L); } if (nullptr != ptr_mem) { delete ptr_mem; ptr_mem = nullptr; }
?