How to get a process ID by executing a file name under 9x

zhaozj2021-02-08  249

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;}

转载请注明原文地址:https://www.9cbs.com/read-1847.html

New Post(0)