SetValue class method

Project: Environment Variables Unit

Unit: PJEnvVars

Class: TPJEnvironmentVars

Applies to: ~>3.0

class function SetValue(const VarName, VarValue: string): Integer;

Description

Sets the value of a given environment variable for the current process. If the environment variable does not exist then it is created.

Parameters:

Returns:

The most likely causes of error are attempting to set the value of an un-named environment variable or when the environment block is full and there is no room for the new value or to create a new variable. A description of any error can be found by passing the error code to SysErrorMessage from the SysUtils or System.SysUtils unit.

Important: Setting an environment variable to the empty string does not delete it from the environment block: use the Delete method to do that.

Note: This method does not update the system’s environment variables, only the copy of the environment maintained by this program. Changes are lost when the program terminates.