急!怎样获得别的窗口的按钮控件的句柄!Windows消息高手请进!

我可以用findwindow取得其他窗口的句柄,但是却不知怎么取得其他窗口中的
Button控件的句柄,该控件的caption属性为“你好”,
取得form2的句柄:
findwindow(0,'form2')
现form2中有button1,该控件的caption属性为“你好”
请问我该怎样才能得到该控件的句柄呢??(form2为别的窗口)
[222 byte] By [QQ150900-认定目标,你就冲吧] at [2008-5-2]
# 1
unit Unit1;

interface

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

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
function mygettext(hwnd:THandle):string;
end;

var
Form1: TForm1;
// function EnumWindowsProc(Hwnd:THandle;lParam:LParam):boolean;Stdcall;
function EnumChildProc(Hwnd:THandle;lParam:LParam):boolean;Stdcall;
implementation

{$R *.dfm}
function TForm1.mygettext(hwnd:THandle):string;
var
buf:pchar;
len:Longint;
begin
Len:=Longint(SendMessage(hWnd,WM_GETTEXTLENGTH ,0,0));
if len>0 then
begin//1
try
getmem(buf,len);
SendMessage(hWnd,WM_GETTEXT,Len+1,Int64(buf));
Result:=strpas(buf);
finally
freemem(buf);
end;
end;//1
end;

function EnumChildProc(Hwnd:THandle;lParam:LParam):boolean;
var
WindowCaption,WindowClass:array[0..254] of Char;
begin
GetClassName(Hwnd,WindowClass,255);
if Pos('BUTTON',UpperCase(StrPas(WindowClass))) > 0 then
begin
// if Form1.mygettext(Hwnd)='Button1' then
// begin
sendmessage(hwnd,WM_LBUTTONDOWN,0,1);
sendmessage(hwnd, WM_LBUTTONUP,0,1);
// end;
end;
Result := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
var
h:hwnd;
begin
h := FindWindow(nil, 'MyForm');
if h<>0 then
begin
// sendmessage(h,WM_close,0,1);
EnumChildWindows(H,@EnumChildProc,0);
end
else
showmessage('No Form');
end;

end.
# 2
var temp,s:integer;
begin
s:=findwindow(0,'form2');
temp:=FindWindowEx(s,0,'Button','你好');
if temp<>0 then showMessage('找到');
end;
# 3
TO: laihongbo524(风铃夜思雨)
试过了,可就是测不出来??

怎办呢???
# 4
laihongbo524(风铃夜思雨) 的方法是可行的.

建议你看看findwindowex这个API的说明

不过有一种情况是无法截取到的,就是它将整个封装啦,作为一个控件发布,就有可能无法取得.
jie115-守望红木 at 2007-10-23 > top of Msdn China Tech,Delphi,Windows SDK/API...