Reputation: 57
I need get the HANDLE
or HWND
of a hidden window to terminate it with EndTask((HWND)hProc,TRUE,TRUE);
. I used all ways listed below but none of them work. When I manually set a handle to a hidden window with spy++, this worked correctly.
NOTE: This window not show with ShowWindow()
and then use FindWindow()
. How does spy++ get and show these handles?
I used:
FindProcessId
and then
hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, id);
or
hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID);
Create process not work: access denied.
FindWindow()
does not work for this hidden window.
How can I get the handle for the hidden window so I can terminate the process?
Upvotes: 4
Views: 2991
Reputation: 1161
FindWindow
will search any type of Windows and it does not matter it's hidden or not.
Maybe your problem with FindWindow
is that, window you were looking for, was child of another one and for this reason you are unable to find that.
So you should use FindWindowEx
and search into children's windows.
Upvotes: 2