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>): string;
function GetParametersFrom(const AParams: string): TArray<string>;

Types

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

Constants

MAX_BUFFER = 2048;

Variables

ShellExecute: TShellCommandFunc = @ShellCommand;

Description

Functions and Procedures

function ShellCommand(const AProgram: string; AParams: TArray<string>): 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
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.

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>): 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

Variables

ShellExecute: TShellCommandFunc = @ShellCommand;
 

Generated by PasDoc 0.16.0.