Back
// PSLMemory.cpp : Implementation of CPSLMemory
#include "stdafx.h"
#include "PSLMemory.h"
/*
Will also use GetPerformanceInfo indirectly!
Rely on article: http://www.codeproject.com/KB/cpp/alloc.aspx?fid=14088&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=407583
*/
CPSLMemory::CPSLMemory()
{
}
HRESULT CPSLMemory::FinalConstruct()
{
return S_OK;
}
void CPSLMemory::FinalRelease()
{
}
void CPSLMemory::GetMemoryInfo(MEMORYSTATUSEX * pMemory)
{
pMemory->dwLength = sizeof(MEMORYSTATUSEX);
::GlobalMemoryStatusEx(pMemory);
}
////////////////////////////////////////////////////////////////////////
// Interface Implementation;
////////////////////////////////////////////////////////////////////////
STDMETHODIMP CPSLMemory::get_MemoryLoad(short * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = (short)Memory.dwMemoryLoad;
PSL_END
}
STDMETHODIMP CPSLMemory::get_TotalPhys(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullTotalPhys / 1024);
PSL_END
}
STDMETHODIMP CPSLMemory::get_AvailPhys(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullAvailPhys / 1024);
PSL_END
}
STDMETHODIMP CPSLMemory::get_TotalPageFile(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullTotalPageFile / 1024);
PSL_END
}
STDMETHODIMP CPSLMemory::get_AvailPageFile(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullAvailPageFile / 1024);
PSL_END
}
STDMETHODIMP CPSLMemory::get_TotalVirtual(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullTotalVirtual / 1024);
PSL_END
}
STDMETHODIMP CPSLMemory::get_AvailVirtual(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullAvailVirtual / 1024);
PSL_END
}
STDMETHODIMP CPSLMemory::get_AvailExtendedVirtual(long * pValue)
{
PSL_BEGIN
MEMORYSTATUSEX Memory;
GetMemoryInfo(&Memory);
*pValue = long(Memory.ullAvailExtendedVirtual / 1024);
PSL_END
}
Top |