Skip to content

LilyStilson/CaptureConsoleOutput

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CaptureConsoleOutput.pas

Procedure that executes console command and redirects it's output to the callback procedure. Should be used only in an asynchronous context (use TThread or TTask.Run()), beucase of TThread.Synchronize() that is used inside the procedure.

Tested with RAD Studio 11.0 Alexandria on Windows 11 (Version 21H2) and macOS 11.6.1 Big Sur.

Usage

uses
  CaptureConsoleUnit;

procedure TForm1.Button1Click(Sender: TObject);
begin
  TTask.Run(procedure begin
    CaptureConsoleOutputSync('ping google.com',
      procedure (const Line: String) begin
        Memo1.Lines.Add(Line);
        Memo1.GoToTextEnd;
      end);
  end);
end;

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages