function EnumWindowsProc(hwnd:HWND;lparam:lPARAM):boolean; stdcall;<br>var<br> pid:^integer;<br>begin<br> new(pid);<br> GetWindowThreadProcessId(hwnd,pid);<br> if pid^=lparam then<br> begin<br> result:=false;<br> setparent(hwnd,form1.handle);<br> SetWindowPos(hwnd, 0, 0, 0, 0, 0, SWP_NOSIZE or SWP_NOZORDER);<br> end<br> else<br> result:=true;<br> dispose(pid);<br>end;<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> StartupInfo:TStartupInfo;<br> ProcessInfo:TProcessInformation;<br>begin<br> FillChar(StartupInfo,SizeOf(StartupInfo),#0);<br> StartupInfo.cb:=SizeOf(StartupInfo);<br> StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;<br> StartupInfo.wShowWindow:=sw_show;<br> CreateProcess(nil,'calc.exe',nil,nil,false,Create_new_console or Normal_priority_class,nil,nil,StartupInfo,ProcessInfo);<br> WaitForInputIdle(ProcessInfo.hProcess, 10000);<br> EnumWindows(@EnumWindowsProc,ProcessInfo.dwProcessId);<br>end;