Unit Utils.Shell

Description

Unit which has functions to work with system operational process execution

Overview

Classes, Interfaces, Objects and Records

Name Description
Class TConsoleWatcher This class aims to run an application that can run indefinitely. This execution takes place through a specific thread, allowing the main application to perform other tasks in the meantime. It is possible to interrupt its execution at any time through the Stop method. It is also possible to obtain the output generated by the application using the GetMessage command.

Functions and Procedures

function ShellCommand(const AProgram: string; AParams: TArray<string>; out AExitCode: Integer): string;
function GetParametersFrom(const AParams: string): TArray<string>;
function CheckIfUserPressedCtrlC(const AFrom: string): Boolean;

Types

TConsoleBuffer = array [1..MAX_BUFFER] of Byte;
TShellCommandFunc = function (const AProgram: string; AParams: TArray<string>; out AExitCode: Integer): string;

Constants

MAX_BUFFER = 2048;
EC_EXCEPTION_RUN_COMMAND = 101;

Variables

ShellExecute: TShellCommandFunc = @ShellCommand;

Description

Functions and Procedures

function ShellCommand(const AProgram: string; AParams: TArray<string>; out AExitCode: Integer): string;

executes a program and returns the output as funciton result and also provide a execution status through AStatus out parameter

Parameters
AProgram
Program name or command to be executed.
AParams
Array of arguments to be passed to the program or command being called
AExitCode
Return the exit code from the executed program.
function GetParametersFrom(const AParams: string): TArray<string>;

Process a raw string and returns an array of strings with the parameters that were separated by spaces, and consider as single parameter a string between double quotes.

Ex: MyArray := GetParametersFrom('hello "that is my message"'); returns an array with two elements: ['hello', 'that is my message']

Parameters
AParams
String parameters separeted by spaces and double quotes.
function CheckIfUserPressedCtrlC(const AFrom: string): Boolean;

This item has no description.

Types

TConsoleBuffer = array [1..MAX_BUFFER] of Byte;

Specific array type for console buffer for reading the output in chunks

TShellCommandFunc = function (const AProgram: string; AParams: TArray<string>; out AExitCode: Integer): string;

function type to execute programs or commands. See ShellCommand function for more info.

Constants

MAX_BUFFER = 2048;

Buffer size for reading the output in chunks

EC_EXCEPTION_RUN_COMMAND = 101;

Exeception message when the program to be executed is not found.

Variables

ShellExecute: TShellCommandFunc = @ShellCommand;

This item has no description.


Generated by PasDoc 1.0.4.