I'm building a application that uses a TProcess
called AProcess
like this:
procedure TFormMain.btCompileClick(Sender: TObject);
begin
AProcess := TProcess.Create(nil);
try
AProcess.CommandLine := 'gcc.exe "' + OpenDialog1.FileName + '"'
+ ' -o "' + OpenDialog2.FileName + '"';
AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
AProcess.Execute;
OutputMemo.Lines.BeginUpdate;
OutputMemo.Lines.Clear;
OutputMemo.Lines.LoadFromStream(AProcess.Output);
OutputMemo.Lines.EndUpdate;
finally
AProcess.Free;
end;
end;
But when I click on the button, I got a console window for some seconds and then it exits and all the output of the process is shown on OutputMemo
, but I've putted the TMemo
because I don't want the console screen. Then I want to know how I can hide this console screen.
I assume you're referring to the TProcess
component that comes with Lazarus. To make a console program start without a console, include the poNoConsole
flag in the Options
property.
AProcess.Options := AProcess.Options + [poNoConsole];
The options available in that property map very closely to the process creation flags for the CreateProcess
API function, where the flag to use is CREATE_NO_WINDOW
.