Solved

GetWindow()

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running shell command from Access 3 72
format the code in java 6 93
Smart Camera scanning and reading information 3 106
Detect file exist or not 3 153
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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.

813 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

9 Experts available now in Live!

Get 1:1 Help Now