procedure TForm1.Button1Click(Sender: TObject);<br> function EnumChildWindowsProc(hwnd: Integer; lparam: Longint):Boolean; stdcall;<br> var<br> buffer: array[0..255] of Char;<br> begin<br> Result := True;<br> GetClassName(hwnd,buffer,256);<br> if StrPas(Buffer)='TEdit' then //找TEdit控件<br> begin<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br> end;<br>var<br> Hand: Integer;<br>begin<br> Hand := FindWindow(nil,'Form2'); //Form2第二个程序的窗口名<br> if Hand<>0 then<br> begin <br> EnumChildWindows(Hand,@EnumChildWindowsProc,Integer(@Hand));<br> SendMessage(Hand,WM_SETTEXT,0,Integer(pchar('Your String')));<br> end;<br>end;