Sorry for my noob question.
I want to write the simple application like the following link.
http://www.pocketgear.com/software_detail.asp?id=14279
I write the code to show heap size of processes, but it only show one process, don't list all process.
What's wrong with my code?
I want to write the simple application like the following link.
http://www.pocketgear.com/software_detail.asp?id=14279
I write the code to show heap size of processes, but it only show one process, don't list all process.
What's wrong with my code?
- Code:
int HeapProcesslistDlg::ShowProcessSize()
{
m_list.SetColumnWidth(0, 140);
m_list.SetColumnWidth(1, 70);
hSnapShot=CreateToolhelp32Snapshot (TH32CS_SNAPALL,NULL);
HEAPENTRY32 pHeap;
pHeap.dwSize= sizeof(HEAPENTRY32);
PROCESSENTRY32 pEntry;
pEntry.dwSize =sizeof(pEntry);
DWORD dwTotal=0;
wchar_t szProcessInfo[255];
Process32First(hSnapShot,&pEntry;);
Heap32First(hSnapShot,&pHeap;,pHeap.th32ProcessID,pHeap.th32HeapID);
do
{
dwTotal += pHeap.dwBlockSize;
pHeap.dwSize= sizeof(HEAPENTRY32);
m_list.InsertItem(0,pEntry.szExeFile);
m_list.SetItemData(0,pEntry.th32ProcessID);
m_list.SetItemText(0,0,pEntry.szExeFile);
swprintf(szProcessInfo,_T("%d"),dwTotal );
m_list.SetItemText(0,1,szProcessInfo);
} while( Heap32Next(hSnapShot,&pHeap;) );
CloseToolhelp32Snapshot( hProcess );
}
Attachments:

