function GetEditHandle(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> //找到目标窗口的目标控件<br> if StrPas(Buffer)='Edit' then<br> begin<br> GetWindowText(hwnd,buffer1,100);<br> PInteger(lparam)^ := hwnd; //得到目标控件的Hwnd(句柄)<br> Result:=False; //终止循环<br> end;<br>end;//end of function<br><br>procedure TfrmMain.bbtnStartClick(Sender: TObject);<br>var<br> Handle: Integer;<br>begin<br> {取句柄}<br> Handle := FindWindow(nil,'对话模式'); //就是窗口的Caption<br> if Handle<>0 then<br> begin<br> //在这里循环取到想要的句柄为止<br> EnumChildWindows(Handle,@GetEditHandle,Integer(@Handle));<br> //此时,Handle就是你要的句柄<br> end;//end of if<br>end;<br><br><br>得到句柄后用postmessage消息就可以了。<br>例如postmessage(handle,WM_KEYDOWN,50,0);<br>向窗口中编辑控件框中输入一个数字2。<br>