TZF - Delphi starting a program from a Delphi-Program

Pierre Wittwer <[email protected]> Wed, 1 Oct 2003 23:14:47 +0200
Newsgroups gmane.comp.lang.delphi.topaz
Message-ID <[email protected]>
Hello

here a Delphi question. I want to start a program from a Delphi-Application.
I found an idea in a german book, but I don't succeed in starting, I get
always th mistake. Is there another possibility to start a program.
Thanks for your help.

Pierre Wittwer
6362 Stans CH



unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Edit2: TEdit;
    procedure Button1Click(Sender: TObject);
  private
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.Button1Click(Sender: TObject);
var StartupInfo: TStartupInfo;
    ProcessInfo: TProcessInformation;

begin
  FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
  StartupInfo.cb := Sizeof(TStartupInfo);
  if CreateProcess(nil,                // Anwendungsname
                   PChar(edit1.text),  // Parameter
                   nil,                // Security
                   nil,                // Security
                   False,
                   NORMAL_PRIORITY_CLASS, // Priorität
                   nil,                   // Environment
                   PChar(edit2.text),     // Verzeichnis
                   StartupInfo,
                   ProcessInfo) then begin
    WaitForSingleObject(ProcessInfo.hProcess, INFINITE);
    CloseHandle(ProcessInfo.hProcess);
    Showmessage('Prozess beendet!');
  end else Showmessage('Fehler!');       // mistake
end;

end.

--^----------------------------------------------------------------
This email was sent to: [email protected]

EASY UNSUBSCRIBE click here: http://topica.com/u/?clvXPN.a5kvff.Z2NsZHQt
Or send an email to: [email protected]

TOPICA - Start your own email discussion group. FREE!
http://www.topica.com/partner/tag02/create/index2.html
--^----------------------------------------------------------------