#include <TlHelp32.h>
DWORD GetProcessPID(const char* ProcName)
{
PROCESSENTRY32 lppe;
long PID = 0, Result = 0;
HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (hSnap)
{
lppe.dwSize = sizeof(PROCESSENTRY32);
Result = Process32First(hSnap, &lppe);
while (Result)
{
if (strcmp(lppe.szExeFile, ProcName) == NULL)
{
PID = lppe.th32ProcessID;
break;
}
Result = Process32Next(hSnap, &lppe);
}
CloseHandle(hSnap);
}
return PID;
}
int main()
{
while (!GetProcessPID("chrome.exe"))
Sleep(500);
ExitProcess(0);
return 0;
}