Created
February 19, 2025 17:57
-
-
Save cs127/53af9dc612a02ea8fb999ed47f2af2e9 to your computer and use it in GitHub Desktop.
pizzablocker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define WIN32_LEAN_AND_MEAN | |
#include <shlwapi.h> | |
#include <windows.h> | |
static BOOL CALLBACK CloseIfHasWord(HWND w, LPARAM word) | |
{ | |
char title [MAX_PATH]; | |
GetWindowTextA(w, title, MAX_PATH); | |
CharLowerA(title); | |
if (StrStrA(title, (PCSTR)word)) | |
{ | |
DWORD pid = 0; | |
HANDLE handle; | |
GetWindowThreadProcessId(w, &pid); | |
if (!pid) goto end; | |
handle = OpenProcess(PROCESS_TERMINATE, FALSE, pid); | |
if (!handle) goto end; | |
TerminateProcess(handle, 1); | |
CloseHandle(handle); | |
} | |
end: | |
return TRUE; | |
} | |
int WinMain(HINSTANCE inst, HINSTANCE prev_inst, LPSTR cmdline, int show) | |
{ | |
while (TRUE) | |
{ | |
EnumWindows(CloseIfHasWord, (LPARAM)"pizza"); | |
Sleep(100); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment