分数太少了!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Edit1: TEdit;
Edit2: TEdit;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
function FindWindowLike(Level:integer;hWndStart:HWND;WindowText:string;WindowClass:string):HWND;
var
hwndLike:HWND;
WndCaption:array[0..254] of char;
WndClassName:array[0..254] of char;
begin
if level=0 then
if hWndStart=0 then hWndStart:=GetDesktopWindow;
level:=level+1;
hwndLike:=GetWindow(hWndStart,GW_CHILD);
while hwndLike<>0 do
begin
FindWindowLike(level,hwndLike,WindowText,WindowClass);
GetWindowText(hwndLike,@WndCaption,254);
GetClassName(hwndLike,@WndClassName,254);
if pos(WindowText,StrPas(WndCaption))<>0 then
if ((pos(WindowClass,StrPas(WndClassName))<>0) or (WindowClass='')) then
begin
form1.Memo1.Lines.Add(StrPas(WndCaption));
form1.Memo1.Lines.Add(StrPas(WndClassName));
form1.Memo1.Lines.Add(inttostr(hwndlike));
form1.Memo1.Lines.Add(StrPas('------------'));
FindWindowLike:=hwndLike;
end; //end if &Otilde;&Ograve;&micro;&frac12;&AElig;&yen;&Aring;&auml;&acute;°&iquest;&Uacute;&Atilde;&ucirc;&sup3;&AElig;&Oacute;&euml;&Agrave;à&Atilde;&ucirc;&raquo;ò&acute;°&iquest;&Uacute;&Atilde;&ucirc;&sup3;&AElig;&AElig;&yen;&Aring;&auml;
hwndLike:=GetWindow(hwndLike,GW_HWNDNEXT);
end;
level:=level-1;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Memo1.Lines.Clear;
FindWindowLike(0,0,Edit1.Text,Edit2.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
hwndclose:HWND;
begin
hwndclose:=FindWindowLike(0,0,Edit1.Text,Edit2.Text);
PostMessage(hwndclose,WM_CLOSE,0,0 );
end;
procedure TForm1.Button3Click(Sender: TObject);
var
hwndtoshow:HWND;
begin
hwndtoshow:=FindWindowLike(0,0,'&acute;ó&cedil;&raquo;&Icirc;&Igrave;',Edit2.Text);
SetForegroundWindow(hwndtoshow);
ShowWindow(hwndtoshow, SW_RESTORE);
hwndtoshow:=FindWindowLike(0,0,'&Iuml;&Ocirc;&Ecirc;&frac34;&Icirc;&Ecirc;&Igrave;&acirc;',Edit2.Text);
SetForegroundWindow(hwndtoshow);
ShowWindow(hwndtoshow, SW_RESTORE);
end;
end.