Recent

Author Topic: [RESOLVIDO] - Como listar janelas abertas no windows?  (Read 3303 times)

FKROBERT

  • New Member
  • *
  • Posts: 18
    • http://fkrobert.bl.ee/
[RESOLVIDO] - Como listar janelas abertas no windows?
« on: March 14, 2014, 04:02:28 am »
axo que é uma funçao parecida com esta mas nao sei usar...


function EnumWindowsProc(Wnd : HWnd;Form : TForm1) : Boolean; Export; {$ifdef Win32} StdCall; {$endif}
var
Buffer : Array[0..99] of char;
begin
GetWindowText(Wnd,Buffer,100);
if StrLen(Buffer) <> 0 then
Form.ListBox1.Items.Add(StrPas(Buffer));
Result := True;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
begin
EnumWindows(@EnumWindowsProc,LongInt(Self));
end; 
« Last Edit: March 14, 2014, 05:55:07 pm by FKROBERT »
"Feliz é aquele que transfere o que sabe e aprende o que ensina" Cora Coralina

-

site pessoal -  http://fkrobert.bl.ee/
:)

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Como listar janelas abertas no windows?
« Reply #1 on: March 14, 2014, 04:54:07 am »
Code: [Select]
uses
  Windows;
...

function EnumWindowsProc(Wnd: HWnd; lParam: LPARAM): bool; stdcall;
var
  Buffer: array[0..99] of char;
begin
  GetWindowText(Wnd, Buffer, 100);
  if StrLen(Buffer) <> 0 then
    TForm1(lParam).ListBox1.Items.Add(StrPas(Buffer));
  Result := True;
end;

{ TForm1 }

procedure TForm1.Button1Click(Sender: TObject);
begin
  EnumWindows(@EnumWindowsProc, LongInt(Self));
end;

Maybe a bit better EnumWindowsProc:
Code: [Select]
function EnumWindowsProc(Wnd: HWnd; lParam: LPARAM): Bool; stdcall;
var
  S: WideString;
  Len: LongInt;
begin
  SetLength(s, 100);
  Len := GetWindowTextW(Wnd, @S[1], Length(S));
  if Len > 0 then
    TForm1(lParam).ListBox1.Items.Add(UTF8Encode(S));
  Result := True;
end;
« Last Edit: March 14, 2014, 05:07:54 am by engkin »

 

TinyPortal © 2005-2018