Solved

GetWindow()

Posted on 1997-06-03
4
467 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
substring method in java 1 130
ShiftLeft challenge 21 86
changeXy challenge 13 89
how to split multiple lines delimiter : 8 111
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 …
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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