Note: Pe.szexefile is sometimes the full-time file name, sometimes it is only the file name, the reason is needed, or which expert
DWORD getProcessidFromName (lpctstr name) {processentry32 pe; dword id = 0;
Handle hsnapshot = CreateToolHelp32Snapshot (TH32CS_SNAPPROCESS, 0); pe.dwsize = sizeof (Processentry32); if (! Process32First (Hsnapshot (HSnapshot, & PE)) Return 0;
Do {pe.dwsize = sizeof (Processentry32); if (Process32Next (HSnapshot, & PE) == false) Break; if (strcmp (pe.szeefile, name) == 0) {ID = pe.th32processid; Break;
WHILE (1);
CloseHandle (HSnapshot);
Return ID;}