没问题的呀,已经测试:<br>function GetComponentHandle(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br>var<br> buffer: array[0..255] of Char;<br>begin<br> Result := True;<br> //得到目标窗口的控件<br> GetClassName(hwnd, buffer, 256);<br> //找到目标窗口的TButton类目标控件<br> if StrPas(Buffer)='TEdit' then<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> AHandle, BHandle: Integer;<br> S:String;<br>begin<br> //取句柄<br> AHandle := FindWindow(nil, '你的窗口'); //就是窗口的Caption<br>// AHandle := GetActiveWindow; //或GetForeGroundWindow;获得当前激活窗体的句柄<br> if AHandle<>0 then<br> begin<br> //在这里循环取到想要的句柄为止<br> EnumChildWindows(AHandle, @GetComponentHandle, Integer(@BHandle));<br> //此时,BHandle就是你要的句柄<br> S:='你好吗?OK吗?';<br> SendMessage(BHandle, WM_SETTEXT, 0, LongInt(lpstr(S)));<br> end;<br>end;<br>