• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 684
  • Last Modified:

Find a hidden window

How do i find a hidden window and close it...
i used :
HWND hWnd = ::FindWindow("Title",NULL);
::SendMessage(hWnd,WM_CLOSE,0,0);

but nothing happens to the hidden window

please help and thanks to anyone who helps
0
zeurx
Asked:
zeurx
  • 3
  • 2
  • 2
1 Solution
 
PriyeshCommented:
The first param to findwindow is the classname, and the second is the title of the window. so to find notepad for instance, you should

HWND hNotePad = ::FindWindow(NULL, "Untitled - Notepad") ;

and then check the window handle and send a close message to it.

if(IsWindow(hNotePad))
{
  SendMessage(hNotePad, WM_CLOSE, 0, 0) ;
}
0
 
zeurxAuthor Commented:
This does not help...

if(IsWindow(hNotePad))
{
 SendMessage(hNotePad, WM_CLOSE, 0, 0) ;
}

in this code SendMessage only takes 3 parts and i can not include my hWnd
this will kill the wrong program and does not want to kill the other program that this program is for :S

please help
and thanks
0
 
codez80Commented:
you need to destroy the window not close it
it may not respond to close message as it is arbitrary

use DestroyWindow(hWnd); or pWnd->DestroyWindow();

codez80
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
zeurxAuthor Commented:
what i need to do is to kill the program... not destroy thw window but kill the program... none of the above has helped... this program takes full cpu and climes in mem use :'( please help
0
 
codez80Commented:
use:

DWORD dwProcessId;
GetWindowThreadProcessId(hWnd, &dwProcessId);
to get the process controlling that window.

then call:
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPorcessId);

and finally:
TerminateProcess(hProcess, 0 /* exit code*/ );

codez80

0
 
PriyeshCommented:
you started out with a question about finding a hidden window and closing it.
Then you are making up questions on the go about killprocess.

use ::SendMessage and it will take 4 params
0
 
zeurxAuthor Commented:
Thanks codez80.... works Great ;)
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now