How to get HWND of one or more hidden windows?

I need to get a HANDLE or HWND hidden window in order to complete it using EndTask((HWND)hProc,TRUE,TRUE); . I used all the paths listed below, but none of them work. When I manually set the descriptor to a hidden window with spy ++, this worked correctly.

NOTE. This window is not displayed using ShowWindow() , and then use FindWindow() . How does spy ++ get and display these descriptors?

enter image description here

I used:

  • FindProcessId

    and then

     hProc = OpenProcess(SYNCHRONIZE|PROCESS_TERMINATE, FALSE, id); 

    or

     hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pe.th32ProcessID); 
  • Create process does not work: access denied.

  • FindWindow() does not work for this hidden window.

How can I get a hidden window handle to complete the process?

+4
source share
1 answer

FindWindow will search for any type of Windows, and it does not matter if it is hidden or not.

Perhaps your problem with FindWindow is that the window you were looking for was a child of another, and for this reason you cannot find it.

So you should use FindWindowEx and search in child windows.

+2
source

Source: https://habr.com/ru/post/1446885/


All Articles