terça-feira, 7 de fevereiro de 2017

DELPHI - Pegar título da janela ativa no Windows - Take title from active window without Windows

Segue abaixo uma função que retornar o título da janela ativa.



function GetTituloAtivo: string;
var
  Handle: THandle;
  Len: LongInt;
  Title: string;
begin
  Result := '';
  Handle := GetForegroundWindow;

  if Handle <> 0 then
  begin
    Len := GetWindowTextLength(Handle) + 1;
    SetLength(Title, Len);
    GetWindowText(Handle, PChar(Title), Len);
    Result := TrimRight(Title);
  end;
end;

Nenhum comentário:

Postar um comentário