Kod
unit Unit1;
 
interface
 
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
 
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    fNotepadHandle:THandle;
    procedure res;
    { Private declarations }
  public
    { Public declarations }
  end;
 
var
  Form1: TForm1;
 
implementation
 
{$R *.dfm}
 
uses ShellAPI;
 
procedure TForm1.res;
begin
  if IsWindow(fNotepadHandle) then begin
    SetWindowPos(fNotepadHandle, 10, 10, 0, 60, 60,
      SWP_SHOWWINDOW);
  end;
end;
 
procedure TForm1.Button1Click(Sender: TObject);
var
  Rec: TShellExecuteInfo;
const
  AVerb = 'open';
  AParams = '';
  AFileName = 'Notepad.exe';
  ADir = '';
begin
  FillChar(Rec, SizeOf(Rec), #0);
 
  Rec.cbSize       := SizeOf(Rec);
  Rec.fMask        := SEE_MASK_NOCLOSEPROCESS;
  Rec.lpVerb       := PChar( AVerb );
  Rec.lpFile       := PChar( AfileName );
  Rec.lpParameters := PChar( AParams );
  Rec.lpDirectory  := PChar( Adir );
  Rec.nShow        := SW_HIDE;
 
  ShellExecuteEx(@Rec);
  WaitForInputIdle(Rec.hProcess, 5000);
  fNotepadHandle := Windows.FindWindow( 'Notepad', nil );
  Res;
  Windows.SetParent( fNotepadHandle,Handle );
  ShowWindow(fNotepadHandle, SW_SHOW);
end;
 
end.