Home > Back-end >  Traverse all the Windows desktop window
Traverse all the Windows desktop window

Time:11-03

All Delphi how to traverse the Windows desktop window

CodePudding user response:

Baidu a handful

CodePudding user response:

Findwindow search window

CodePudding user response:

The EnumWindows function enumerates all top - level Windows on The screen by passing The handle of each window, in turn, to an application - defined callback function. EnumWindows continues until The last top - level window is enumerated or The callback function returns FALSE.

BOOL EnumWindows (

WNDENUMPROC lpEnumFunc,//a pointer to the callback function
LPARAM LPARAM//application - defined value
);


The Parameters

LpEnumFunc

Points to an application - defined callback function. For more information, see the EnumWindowsProc callback function.

LParam

Specifies a 32 - bit, application - defined the value to be passed to the callback function.



The Return Values

If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero.

Few

The EnumWindows function does not enumerate child Windows.
This function is more reliable than calling the GetWindow function in a loop. An application that calls GetWindow to perform This task risks being caught in An infinite loop or referencing a handle to a window that has had been destroyed.

See Also

EnumChildWindows EnumWindowsProc, GetWindow

CodePudding user response:

The many examples

CodePudding user response:

The function EnumWndProc (AhWnd: LongInt; AlParam: lParam) : Boolean; Stdcall;
Var
WndClassName: an array of Char [0.. 254];
WndCaption: an array of Char [0.. 254];
The begin
GetClassName (AhWnd wndClassName, 254);
GetWindowText (aHwnd WndCaption, 254);
//if WndCaption='FastHelper then
The begin
With form1. Memo1 do
The begin
Form1. Memo1. Lines. The Add (IntToStr (AhWnd) + WndCaption);
end;
end;
Result:=true;
end;



Procedure TForm1. Button1Click (Sender: TObject);
The begin
EnumWindows (@ EnumWndProc, LongInt (self));
end;
  • Related