Solved

Get the title of a window by its handle

Posted on 2001-07-11
3
172 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
  • 2
3 Comments
 
LVL 22

Expert Comment

by:mnasman
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:mnasman
ID: 6272653
oops

you are right Igor, i made that in fly
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

746 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

12 Experts available now in Live!

Get 1:1 Help Now