Skip to content

Latest commit

 

History

History
39 lines (23 loc) · 1.75 KB

TPJCustomConsoleApp-Environment.md

File metadata and controls

39 lines (23 loc) · 1.75 KB

Environment property

Project: Console Application Runner Classes

Unit: PJConsoleApp

Classes: TPJCustomConsoleApp, TPJConsoleApp

Applies to: ~>3.0

property Environment: Pointer;

Description

Environment references the environment block to be used by the console application or is nil if the child process is to inherit the parent process' environment block.

If the property is not nil then the memory it points to must not be freed until the console application has finished executing.

The default value is nil.

Remarks

To give a console application its own environment block you must:

  • Allocate memory for the environment block.
  • Set up the environment block containing the required environment variables.
  • Set the Environment property to point to the environment block.
  • Execute the console application.
  • Free the environment block.

See this article and its demo code for information on setting up environment blocks.

[>=3.0 & <3.1] The environment variables contained in the block must be encoded as a sequence of AnsiChar characters regardless of whether a Unicode or ANSI Delphi compiler is used.

[~>3.1] The environment variables contained in the block must be stored as a sequence of WideChar characters if the UnicodeEnvironment property is True or as a sequence of AnsiChar characters otherwise. Important: The memory allocated for the block must allow for the size of characters used.

The property is public in TPJConsoleApp and protected in TPJCustomConsoleApp.