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?

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?
source share