CallBack.pas
上传用户:psxgmh
上传日期:2013-04-08
资源大小:15112k
文件大小:1k
- 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.