Welcome to the new DelphiDabbler Code Library Documentation.

This is a new site that's currently running on alpha code. There are going to be bugs. If you discover any, please report them on the site's issues page (GitHub account required). Thanks.

Warning: Many URLs are going to change. Refer to the README file to discover which library project's documentation has been completed.

Values property

Project: Environment Variables Unit

Unit: PJEnvVars

Class: TPJEnvVars

Applies to: ~>3.0

property Values[Name: string]: string;

⚠️ TPJEnvVars has been deprecated. Use the TPJEnvironmentVars.GetValue and TPJEnvironmentVars.SetValue static methods instead of the Values property.

Description

This property enables the current process’ environment variables to be read and written by name.

To get the value of an environment variable treat the property as an array of values indexed by the environment variable name. For example Value['Foo'] returns the value of an environment variable named FOO. If there is no environment variable with the required name then the empty string is returned.

Values of existing environment variables can be set by assigning string values to the property, indexed by the required environment variable name. For example Values['Foo'] := 'Bar' sets the environment variable FOO to have value 'Bar'. If no environment variable with the given name exists, a new variable is created and set to the required value.

If an error occurs when setting an environment variable, for example if the environment space is full, a EPJEnvVars exception is raised.

Note: Changing an environment variable by setting this property effects only this program’s copy of the environment. It has no effect on the system’s environment variables. Any changes are lost when the program closes.

The names of all current environment variables can be found using the EnumNames method.