📄 callback.pas
字号:
unit CallBack;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
EnumWindowsProcedure = function (Hwnd: THandle;Param: Pointer): Boolean; stdcall;
TForm1 = class(TForm)
ListBox1: TListBox;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
function GetAllRuningWindowTitle(Hwnd: THandle; Param: Pointer): Boolean; stdcall;
var
WindowCaptionText: string;
begin
SetLength (WindowCaptionText, 100);
GetWindowText(Hwnd, PChar (WindowCaptionText), 100);
Form1.ListBox1.Items.Add ('句柄为'+IntToStr (Hwnd) + '的窗体的标题为:'+WindowCaptionText);
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
MYEWProc: EnumWindowsProcedure;
begin
ListBox1.Items.Clear;
MYEWProc := GetAllRuningWindowTitle;
EnumWindows(@MYEWProc, 0);
ShowMessage('当前系统中正在运行的窗体一共有:'+IntToStr(Listbox1.Items.Count)+'个.');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -