?
Solved

Find a hidden window

Posted on 2003-02-22
7
Medium Priority
?
663 Views
Last Modified: 2013-11-20
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
Comment
Question by:zeurx
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:Priyesh
ID: 8002001
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
 

Author Comment

by:zeurx
ID: 8003505
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
 
LVL 1

Expert Comment

by:codez80
ID: 8003625
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
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!

 

Author Comment

by:zeurx
ID: 8003981
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
 
LVL 1

Accepted Solution

by:
codez80 earned 600 total points
ID: 8004057
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
 
LVL 9

Expert Comment

by:Priyesh
ID: 8004375
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
 

Author Comment

by:zeurx
ID: 8004930
Thanks codez80.... works Great ;)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question