CreateToolhelp32Snapshot

App 에서 프로세스 정보 얻기.. (MSDN CreateToolhelp32Snapshot 샘플 참조)

#include “Tlhelp32.h”

void GetProcessInfo()
{
HANDLE hProcessSnap;
PROCESSENTRY32 pe32;

hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

if(hProcessSnap == INVALID_HANDLE_VALUE )
{
return;
}

pe32.dwSize = sizeof(PROCESSENTRY32);

if(!Process32First(hProcessSnap, &pe32))
{
CloseHandle(hProcessSnap);
return;
}

do
{
TRACE1(“ProcessID : [%d]\n”, pe32.th32ProcessID);
TRACE1(“ProcessName : [%s]”, pe32.szExeFile);
} while(Process32Next(hProcessSnap, &pe32));

CloseHandle( hProcessSnap );

return;
}