Answer the question
In order to leave comments, you need to log in
How to check if a process exists by name?
Greetings. There is a list of process names, you need to check their presence. I wrote this code, but the problem is with encodings.
bool CheckProcesses(const char* processName)
{
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe;
pe.dwSize = sizeof(PROCESSENTRY32);
if (Process32First(hSnapshot, &pe) == TRUE)
{
while (Process32Next(hSnapshot, &pe) == TRUE)
{
if (strcmp(pe.szExeFile, processName))
{
return true;
}
}
}
return false;
}
bool IsProcessRun() {
const char* szExe[] = { "Sysmon64.exe", "sysmon.exe", "CFService.exe" };
for (int i = 0; i < sizeof(szExe); i++) {
if (CheckProcesses(szExe[i]))
return true;
}
return false;
}
Answer the question
In order to leave comments, you need to log in
This might help: https://stackoverflow.com/questions/2573834/c-conv...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question