Sign in Join
FPDoc Onlineexperiment

TProcess class

In unit Process

Class to start and control other processes.

Declaration

pascal
TProcess = class(TComponent)

Inheritance

  1. TProcess
  2. TComponent
  3. TPersistent
  4. TObject

Descends from it: TProcessUTF8

Description

TProcess is a component that can be used to start and control other processes (programs/binaries). It contains a lot of options that control how the process is started. Many of these are Win32 specific, and have no effect on other platforms, so they should be used with care.

The simplest way to use this component is to create an instance, set the CommandLine property to the full pathname of the program that should be executed, and call Execute. To determine whether the process is still running (i.e. has not stopped executing), the Running property can be checked.

More advanced techniques can be used with the Options settings.

See also

Properties

WindowRectpublicPositions for the main program window.
HandlepublicHandle of the process.
ProcessHandlepublicAlias for Handle.
ThreadHandlepublicMain process thread handle.
ProcessIDpublicID of the process.
ThreadIDpublicID of the main process thread.
InputpublicStream connected to standard input of the process.
OutputpublicStream connected to standard output of the process.
StderrpublicStream connected to standard diagnostic output of the process.
ExitStatuspublicExit status of the process.
ExitCodepublicExit code of the process.
InheritHandlespublicShould the created process inherit the open handles of the current process.
RunCommandSleepTimepublicSleep time between attempts to collect data.
PipeBufferSizepublishedBuffer size to be used when using pipes.
ActivepublishedStart or stop the process.
ApplicationNamepublishedName of the application to start (deprecated).
CommandLinepublishedCommand-line to execute (deprecated).
ExecutablepublishedExecutable name. Supersedes CommandLine and ApplicationName.
ParameterspublishedCommand-line arguments. Supersedes CommandLine.
ConsoleTitlepublishedTitle of the console window.
CurrentDirectorypublishedWorking directory of the process.
DesktoppublishedDesktop on which to start the process.
EnvironmentpublishedEnvironment variables for the new process.
OptionspublishedOptions to be used when starting the process.
PrioritypublishedPriority at which the process is running.
StartupOptionspublishedAdditional (Windows) startup options.
RunningpublishedDetermines whether the process is still running.
ShowWindowpublishedDetermines how the process main window is shown (Windows only).
SkipCommandLineQuotespublished
WindowColumnspublishedNumber of columns in console window (windows only).
WindowHeightpublishedHeight of the process main window.
WindowLeftpublishedX-coordinate of the initial window (Windows only).
WindowRowspublishedNumber of rows in console window (Windows only).
WindowToppublishedY-coordinate of the initial window (Windows only).
WindowWidthpublishedHeight of the process main window (Windows only).
FillAttributepublishedColor attributes of the characters in the console window (Windows only).
XTermProgrampublishedXTerm program to use (UNIX only).
InputDescriptorpublished
OutputDescriptorpublished
ErrorDescriptorpublished

Methods

CloseProcessHandlesprotected
LoadedprotectedCalled when the component has finished loading.
SysExecuteprotected
CreateIODescriptorprotected
CreatepublicCreate a new instance of the TProcess class.
DestroypublicDestroy this instance of TProcess.
ExecutepublicExecute the program with the given options.
CloseInputpublicClose the input stream of the process.
CloseOutputpublicClose the output stream of the process.
CloseStderrpublicClose the error stream of the process.
ResumepublicResume execution of a suspended process.
SuspendpublicSuspend a running process.
TerminatepublicTerminate a running process.
WaitOnExitpublicWait for the program to stop executing.
ReadInputStreampublicRead available data from input stream.
RunCommandLooppublicExecute command and collect output in strings.

Events

OnRunCommandEventpublicEvent handler, called when RunCommandLoop is executing.
OnForkEventpublicEvent triggered after fork occurred on Linux.

Fields

FRunningprotected
FExitCodeprotected
FProcessIDprotected
FThreadIDprotected
FProcessHandleprotected
FThreadHandleprotected

Inherited

From TComponent (73)

_AddRef _Release BeforeDestruction CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DefineProperties DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetChildren GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetParentComponent GetTypeInfo GetTypeInfoCount HasParent iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name Notification ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReadState ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetChildOrder SetDesigning SetDesignInstance SetInline SetName SetParentComponent SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState

From TPersistent (5)

Assign AssignTo FPOAttachObserver FPODetachObserver FPONotifyObservers

From TObject (37)

AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.