下面的代码可以的<br>function EnumChildProc(hwnd: HWND; lParam: LPARAM): BOOL; stdcall;<br>var<br>wtext: Array[0..255] of Char;<br>begin<br>Getwindowtext(hwnd, @wtext, 255);<br>if SameText(wtext, 'formchild') then //子窗口标题<br> PostMessage(hwnd, WM_close, 0, 0); //发wm_close消息<br>Result := True;<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> whandle:hwnd;<br>begin<br> whandle:=findwindow(nil,'formmain'); //主窗口窗体的标题<br> if whandle=0 then<br> showmessage('window not find')<br> else<br> begin<br> EnumChildWindows(whandle,@EnumChildProc,0);<br> end;<br><br>end;