Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2005 May : How get the memory used by one process ( like the one shown in task manager )
| Subject: | How get the memory used by one process ( like the one shown in task manager ) |
| Posted by: | "enzo" (enzo.arla..@aesys.it) |
| Date: | Mon, 23 May 2005 10:24:57 |
object: How get the memory used by one process ( like the one shown in task
manager )
I want to build a routine which allowe me to detect the total used memory by
a process.
I tried using some code like the follow but the result I got is different
from the one showed in task manager:
LPCVOID lpAddress;
MEMORY_BASIC_INFORMATION mbi;
HANDLE hProcess = GetCurrentProcess();
ZeroMemory(&mbi,sizeof(mbi));
mbi.BaseAddress=0;
mbi.AllocationBase=0;
mbi.RegionSize=0;
mbi.AllocationProtect=PAGE_READWRITE;
mbi.State= MEM_FREE | MEM_COMMIT | MEM_RESERVE;
VirtualQueryEx(hProcess, lpAddress, &mbi, sizeof(mbi));
StatusBar1->Panels->Items[1]->Text = String(mbi.RegionSize);
I suppose this code is wrong but I didn't know how is wrong.
Can someone help me ?
Regards, Ezno