DelphiDabbler Wiki



Console Application Runner ClassesTPJConsoleApp class

Project: Console Application Runner Classes

Unit: PJConsoleApp.

Introduced: v1.0

Description

This class is designed to be used to control the execution of child console application processes. The class provides facilities to redirect the console process' standard input, output and error handles. The application's execution can be given a time-out and can be time sliced to allow progress to be reported and redirected output to be handled while the console application continues to execute. Security levels and environment blocks can be customised. Errant processes can be terminated. Finally, the program's exit code is made available.

TPJConsoleApp descends from TPJCustomConsoleApp. The only differences are that TPJCustomConsoleApp declares all properties and events as protected whereas TPJConsoleApp makes them all public.

Methods

MethodDescription
ExecuteExecutes the console application.
TerminateAttempts to terminate the console application process.

Properties

PropertyDescription
CommandLine[v2.0] Command line used to execute a console application.
ConsoleColors[v2.0] Foreground and background colours used in console window.
ConsoleTitleTitle to be displayed in any new console window.
CurrentDir[v2.0] Application's current directory.
ElapsedTimeApproximate time in milliseconds since the console application began executing.
EnvironmentPointer to the environment block used by the console application.
ErrorCodeProvides information about any error that occurred while attempting to run a console application.
ErrorMessageError message corresponding to any non-zero value of ErrorCode.
ExitCodeExit code returned by the console application on completion.
KillTimedOutProcessIndicates whether timed-out processes should be terminated or left running.
MaxExecTimeMaximum permitted execution time of the console application.
PriorityPriority with which the console application is started.
ProcessAttrsSpecifies security and inheritance attributes for the console application process.
ProcessInfoProvides process information for the executing console application.
ScreenBufferSize[v2.0] Size of console's screen buffer.
StdErrThe console application's standard error handle.
StdInThe console application's standard input handle.
StdOutThe console application's standard output handle.
ThreadAttrsSecurity and inheritance attributes for the console application's primary thread.
TimeSliceLength of each time slice for a timed sliced console application.
TimeToLiveAmount of time a console application has left to run before timing out.
UnicodeEnvironment[v3.1] Determines whether environment block referenced by Environment is in Unicode or ANSI.
UseNewConsoleDetermines if a console application opens a new console window when run.
VisibleDetermines whether the console application is to be displayed.
WindowPosition[v2.0] Position of console window on screen.
WindowSize[v2.0] Size of console window.

Events

EventDescription
OnCompleteTriggered when an application completes or times out.
OnStart[v2.0] Triggered after a console application process is created and just before it starts executing.
OnWorkTriggered when the executing application yields control to this class. Permits necessary work to be completed.

See Also

Page last modified on August 11, 2014, at 10:35 AM