My friend Glenn9999 from tek-tips.com wrote a good FAQ on this . I do not know if he was SO, but he deserves all of this. I copied the code from this page here for future reference. It uses channels for communication between the console and delphi.
unit mcunit; { written by Glenn9999 @ tek-tips.com. Posted here 6/21/2011 } interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type monitor = class(TThread) // pipe monitoring thread for console output private TextString: String; procedure UpdateCaption; protected procedure Execute; override; end; TForm1 = class(TForm) CommandText: TMemo; CommandRun: TComboBox; Button2: TButton; SaveDialog1: TSaveDialog; procedure FormDestroy(Sender: TObject); procedure Button2Click(Sender: TObject); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } cmdcount: integer; end; var Form1: TForm1; InputPipeRead, InputPipeWrite: THandle; OutputPipeRead, OutputPipeWrite: THandle; ErrorPipeRead, ErrorPipeWrite: THandle; ProcessInfo : TProcessInformation; myThread: monitor; implementation {$R *.DFM} procedure WritePipeOut(OutputPipe: THandle; InString: string); // writes Instring to the pipe handle described by OutputPipe var byteswritten: DWord; begin // most console programs require CR/LF after their input. InString := InString +
source share