unit Main;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, Buttons, ExtCtrls;

type
  TMainForm = class(TForm)
    Panel1: TPanel;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    procedure BitBtn1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);

  private

  public
	 function  Uruchom_proces() : Boolean;
  end;

var
  MainForm: TMainForm;

implementation
{$R *.dfm}
{------------------------------------------------------------------------------}
procedure TMainForm.BitBtn1Click(Sender: TObject);
begin
	Close();
end;

procedure TMainForm.BitBtn2Click(Sender: TObject);
begin
   Uruchom_proces();
end;

function TMainForm.Uruchom_proces() : Boolean;
var
	ret : Boolean;
   si  : STARTUPINFO;
   pi  : PROCESS_INFORMATION;

begin
	ret := true;

   ZeroMemory(@si, sizeof(si));
   si.cb := sizeof(si);
	ZeroMemory(@pi, sizeof(pi));

	if CreateProcess(Nil,      							                             // pointer to name of executable module
                    'C:\Program Files\Internet Explorer\iexplore.exe',          // pointer to command line string
                    Nil,									                             // pointer to process security attributes
                    Nil,                     		                             // pointer to thread security attributes
                    false,               	   		                             // handle inheritance flag
                    0,                             	    						     // creation flags
                    Nil,	                  		                             // pointer to new environment block
                    Nil,               	   		                             // pointer to current directory name
                    &si,                      		                             // pointer to STARTUPINFO
                    &pi ) then                 			                          // pointer to PROCESS_INFORMATION
   begin
	  WaitForSingleObject(pi.hProcess, INFINITE);
   end
   else begin
	  ret := false;
   end;

   CloseHandle(pi.hProcess);
   CloseHandle(pi.hThread);

	Result := ret;
end;

end.

