Here is my problem:
I want to get the HWND of every window that is running and terminate the window except my own window
(it's for a program to protect my computer).
I just can't get it good to work, I have tried many things but all didn't work, here is some code:
What goes wrong: first of all, it doesn't do anything, but if I press Ctrl + Alt + Delete it immediate terminates the Windows Task Manager,
//In the infinity loop, near the PeekMessage function
Other_Window = GetWindow ( Main_Window, GW_HWNDPREV );//Get a window from the taskbar
if ( Main_Window != Other_Window )//Check if it is my own window
GetWindowThreadProcessId ( Other_Window, & Process_ID );
HANDLE Illigal_Process = OpenProcess ( PROCESS_TERMINATE, FALSE, Process_ID );
TerminateProcess ( Illigal_Process, 0 );
CloseHandle ( Illigal_Process );
which is good but all the other applications are still running and if I press on the Taskbar the code terminates explorer.exe.
I tried to prevent this by: GetDesktopWindow() != Other_Window, doesn't work.
How can I get all the HWND's of visible windows in the taskbar to terminate them that only my program stands and without terminating explorer.exe?