Solved

How to GetWindowText() without sending

Posted on 1997-09-10
5
548 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
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…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

760 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

23 Experts available now in Live!

Get 1:1 Help Now