Created
April 1, 2015 09:09
-
-
Save RIscRIpt/60fa3f3fcbeca5df0730 to your computer and use it in GitHub Desktop.
Get Process ID by Name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DWORD GetProcessIdByName(char *name) { | |
PROCESSENTRY32 pe; | |
pe.dwSize = sizeof(pe); | |
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); | |
Process32First(hSnapshot, &pe); | |
do { | |
if(!strcmp(pe.szExeFile, name)) | |
break; | |
} while(Process32Next(hSnapshot, &pe)); | |
CloseHandle(hSnapshot); | |
return pe.th32ProcessID; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment