#processListEntry - No Match

2 messages · Page 1 of 1 (latest)

glacial oar
#

This is driving me absolutely insane.
Stackoverflow answers say the same thing. Trying to find process by name.

Print statement returns the first character of the process names listed in the hSnapshot.
I'm guessing this is why there's no match.

Regardless of which method I use the result is the same.
Comparing processName to the first character in hSnapshot, which is obviously useless.

function(const char processName[])

    PROCESSENTRY32 processListEntry;
    processListEntry.dwSize = sizeof(PROCESSENTRY32);

    if (Process32First(hSnapshot, &processListEntry)) {
        do {
            cout <<processListEntry.szExeFile<< "\n";
            if ((WCHAR*)processName == processListEntry.szExeFile) {
                pid = processListEntry.th32ProcessID;
                break;
            }
            else { cout <<processName<< " not found" << "\n"; }
        } while (Process32Next(hSnapshot, &processListEntry));
    }
/*
  >> S(ystem.exe)
  >> E(xplorer.exe)
  >> p(rocess.exe)
  >> m(icorosoft_edge.exe)

  >> "process.exe not found"
*/
glacial oar
#

It doesn't make sense to me that using a Do statement would parse it any differently.