Solved

GetWindow()

Posted on 1997-06-03
4
457 Views
Last Modified: 2013-11-20
I would like to be able to get hold of the Window's handles of programs which are currently running. (eg MS Spy++ does this)

How do I do this?

I know its something to do with the GetWindow function but Ive been able to get hold of the HWNDLAST window which is rather frustrating.
Thanks in advance
Ian Robertson
0
Comment
Question by:yakky
  • 2
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
AVaulin earned 80 total points
ID: 1301946
Use h=GetWindow( NULL, GW_HWNDFIRST ) to find first and GetNextWindow( h, GW_HWNDNEXT ) to find next window(s).
0
 

Author Comment

by:yakky
ID: 1301947
Prehaps Im missing something, here but all Im getting is a Null
see bellow. Also if pos I would like to use the CWnd approach
.
HWND h;
h=::GetWindow(NULL,GW_HWNDFIRST);
for(int count=0; count<10; count++)
{
h=::GetWindow(h,GW_HWNDNEXT);
if (h==NULL) TRACE("failed\n");
    //pWnd.GetWindowText(my1);
   //TRACE("m=%s*\n",my1);
TRACE("window=%d*\n"5,h);
}
0
 
LVL 4

Expert Comment

by:AVaulin
ID: 1301948
OK. Here is code. It gave all windows which Spy++ did:

#include <windows.h>
int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
{
 HWND h;
 h = GetDesktopWindow();
 h = GetWindow( h, GW_CHILD );
 while( h )
 {
 // do what you want
  h = GetWindow( h, GW_HWNDNEXT );
 }
 return TRUE;
}
0
 

Author Comment

by:yakky
ID: 1301949
Thanks very much...

Ian (The incompetent) Robertson
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
viewing source code from eclipse 13 74
countEvens challenge 2 58
lucky13 challenge 11 112
fix34  challenge 9 96
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

707 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now