首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > .NET >

findwindow 如何找同时有好几个窗口标题一样的程序了

2012-03-09 
findwindow 怎么找同时有好几个窗口标题一样的程序了比如同一个程序运行了好多个,标题名也是一样的,用find

findwindow 怎么找同时有好几个窗口标题一样的程序了
比如同一个程序运行了好多个,标题名也是一样的,用findwindow想得到第三个窗口的句柄要怎么做了

[解决办法]
枚举窗口EnumWindows
[解决办法]
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;
function EnumWindowsFunc(Handle: THandle; List: TStringList) : boolean ; stdcall;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Clear;
EnumWindows(@EnumWindowsFunc, LParam(Memo1.Lines));
end;

function EnumWindowsFunc(Handle: THandle; List: TStringList) : boolean ; stdcall;
var Caption: array[0..256] of Char;
begin
if GetWindowText
(Handle, Caption, SizeOf(Caption)-1) <> 0 then
begin
List.Add(Caption);
SetWindowText(Handle, PChar( 'About - ' + Caption));
end;

Result :=True;
end;


end.

热点排行