MCPcopy Create free account
hub / github.com/AlSch092/UltimateAntiCheat / GetProcessIdByName

Method GetProcessIdByName

Process/Process.cpp:269–289  ·  view source on GitHub ↗

GetProcessIdByName - Get first pid given a process name. You should probably use GetProcessIdsByName instead. returns a DWORD pid if procName is a running process, otherwise returns 0 */

Source from the content-addressed store, hash-verified

267 returns a DWORD pid if procName is a running process, otherwise returns 0
268*/
269DWORD Process::GetProcessIdByName(__in const wstring procName)
270{
271 PROCESSENTRY32 entry;
272 entry.dwSize = sizeof(PROCESSENTRY32);
273 DWORD pid = 0;
274
275 HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
276
277 if (Process32First(snapshot, &entry) == TRUE)
278 {
279 while (Process32Next(snapshot, &entry) == TRUE)
280 if (wcscmp(entry.szExeFile, procName.c_str()) == 0)
281 {
282 pid = entry.th32ProcessID;
283 break;
284 }
285 }
286
287 CloseHandle(snapshot);
288 return pid;
289}
290
291
292/*

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected