列出在任务栏有按钮的窗口

I

import

Unregistered / Unconfirmed
GUEST, unregistred user!
function GetText(Wnd : HWND):string; var textlength : integer;
text : PChar;
begin
textlength:=SendMessage(Wnd,WM_GETTEXTLENGTH,0,0);
if textlength=0 then Result := ''
else
begin
getmem(text,textlength+1);
SendMessage(Wnd,WM_GETTEXT,textlength+1,Integer(text));
Result:=text;
freemem(text);
end;
end;
Function EnumWindowsProc (Wnd: HWND; LParam: LPARAM): BOOL; stdcall;
begin
Result := True;
if (IsWindowVisible(Wnd) or IsIconic(wnd)) and
((GetWindowLong(Wnd, GWL_HWNDPARENT) = 0) or
(GetWindowLong(Wnd, GWL_HWNDPARENT) = GetDesktopWindow)) and
(GetWindowLong(Wnd, GWL_EXSTYLE) and WS_EX_TOOLWINDOW = 0) then
Form1.Listbox1.items.add('Handle: ' + Inttostr(Wnd) + ',Text: ' +GetText(Wnd));
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
Param : Longint;
begin
EnumWindows(@EnumWindowsProc , Param);
end;
 
 
顶部