Solved

Get the title of a window by its handle

Posted on 2001-07-11
3
178 Views
Last Modified: 2010-07-27
Hi,
How can I get the title of a window if I know the handle of that window?  Maybe GetWindowText can help, but I don't know the way to use it...Can anyone show me how to use it?

Thx.
0
Comment
Question by:nyt
[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
3 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6272450
Hello

yes you are right, you can use GetWindowText, it's easy to use


procedure TForm1.Button1Click(Sender: TObject);
var
  s : pchar;
begin
  GetWindowText(handle,s,255);
  showmessage(s);
end;

Best regards
Mohammed
0
 
LVL 9

Accepted Solution

by:
ITugay earned 25 total points
ID: 6272603
Hi nyt,
mnasman, wrong way. You should allocate memory for returning result.

procedure TForm1.SpeedButton1Click(Sender: TObject);
var
  //s : pchar; // will produce an exception!
  S: array[0..255] of char; // the way to allocate 256 byte for string buffer
begin
  GetWindowText(handle,s,255);
  showmessage(s);
end;

-----
Igor.
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6272653
oops

you are right Igor, i made that in fly
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month10 days, 17 hours left to enroll

632 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