GetWindowTitle function
Return to Introduction  Previous page  Next page
Unit
acUtils  

Declaration
function GetWindowTitle(Wnd: hWnd): String;  

Description
The GetWindowTitle function retrieves the title of window by its handle.  

Original code
function GetWindowTitle(Wnd: hWnd): String;  
var  
  WindowTitleLength: Integer;  
begin  
  WindowTitleLength := GetWindowTextLength(Wnd) + 1;  
  SetLength(Result, WindowTitleLength);  
  if WindowTitleLength <> 1 then  
    Windows.GetWindowText(Wnd, @Result[1], WindowTitleLength);  
  SetLength(Result, WindowTitleLength - 1);  
end;