Skip to content

Instantly share code, notes, and snippets.

@RIscRIpt
Created April 1, 2015 09:09
Show Gist options
  • Save RIscRIpt/60fa3f3fcbeca5df0730 to your computer and use it in GitHub Desktop.
Save RIscRIpt/60fa3f3fcbeca5df0730 to your computer and use it in GitHub Desktop.
Get Process ID by Name
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