Add GetExplorerPID to utils.cpp

This commit is contained in:
toneillcodes
2026-05-01 08:56:46 -04:00
committed by GitHub
parent 9fd17692a4
commit 99efbd098f
+17 -1
View File
@@ -75,4 +75,20 @@ int my_wcsicmp(const wchar_t* s1, const wchar_t* s2) {
} while (c1 == c2);
return c1 - c2;
}
}
// Helper to find Explorer PID
DWORD GetExplorerPID() {
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
PROCESSENTRY32 pe = { sizeof(pe) };
if (Process32First(hSnapshot, &pe)) {
do {
if (lstrcmpiW(pe.szExeFile, L"explorer.exe") == 0) {
CloseHandle(hSnapshot);
return pe.th32ProcessID;
}
} while (Process32Next(hSnapshot, &pe));
}
if (hSnapshot) CloseHandle(hSnapshot);
return 0;
}