Solved

GetWindow()

Posted on 1997-06-03
4
471 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
[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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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…
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.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…

690 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