Solved

How to GetWindowText() without sending

Posted on 1997-09-10
5
549 Views
Last Modified: 2013-12-03
I need to get the window caption of any window in the system. To avoid trouble with calling GetWindowText() on hung applications, I'd like to read the window title directly without sending it WM_GETTEXT. Is this possible?

I know I could use SendMessageCallback() but I wouldn't like to go into all that trouble. Simple tests with Microsoft Spy++ showed that it was capable of reading window titles of hung applications.
0
Comment
Question by:mikkon
5 Comments
 
LVL 15

Expert Comment

by:Tommy Hui
ID: 1406513
Spy++ works differently. It has a hook that watches the window messages so it can save the information before it hangs. It may also have access to hidden information (undocumented information).
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1406514
Looking at Spy source code - it seems to use GetWindowText.

0
 
LVL 7

Expert Comment

by:faster
ID: 1406515
I think you can still use GetWindowText, to avoid hanging, you can create a number of threads, each thread will can this API, your main thread can monitor the behaviour of them and decide to let a hanging thread terminate and create a new one.  Of course, this is somehow complex to implement.
0
 
LVL 1

Author Comment

by:mikkon
ID: 1406516
Messing with several threads would be much more difficult than using SendMessageCallback().

I tested this with Spy++ (no source available, I guess?) so that I hung my application and then started Spy. It was capable of reading the title of my hung application so it probably uses some undocumented features. :-(
0
 
LVL 3

Accepted Solution

by:
byang earned 100 total points
ID: 1406517
Just use SendMessageTimeout().

Still, you should launch threads. If you use a timeout value of 1 second, and there're 3 hang programs having a total of 15 windows, your app. could timeout 15 seconds.

BTW, just because an application is hung doesn't mean calling GetWindowText() on it will hang.


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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.

932 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

11 Experts available now in Live!

Get 1:1 Help Now