I’m trying to use the function GetProcessMemoryInfo of psapi.h inside a C++ application on Windows 7 32-bit.
I followed some tutorial and I did something like:
PPROCESS_MEMORY_COUNTERS pMemCountr;
pMemCountr = new PROCESS_MEMORY_COUNTERS();
bool result = GetProcessMemoryInfo(GetCurrentProcess(),
pMemCountr,
sizeof(PPROCESS_MEMORY_COUNTERS));
The problem is that i always obtain “false” from the execution of the GetProcessMemoryInfo() method. What am I doing wrong here?
The problem is
yields the size of
PPROCESS_MEMORY_COUNTERSwhich is aPROCESS_MEMORY_COUNTERS*type pointer (note doublePin the beginning).What you want is
Also you’ll be much better off without
newhere: