Root > Reference > All Functions > ExpandEnvVars

Function ExpandEnvVars

Previous pageReturn to chapter overviewNext page   

Expands environment-variable strings.

 

Unit

ESysInfo

 

Syntax

 

Code (Delphi)

function ExpandEnvVars(

const ASource: String;

AGetEnvVariable: TGetEnvVariableFunc = nil

): String; overload;

 

function ExpandEnvVars(

const ASource: String;

AGetEnvVariable: TGetEnvVariableMethod

): String; overload;

 

Parameters

ASource [in]

A buffer that contains one or more environment-variable strings in the form: %variableName%. For each such reference, the %variableName% portion is replaced with the current value of that environment variable.

 

Case is ignored when looking up the environment-variable name. If the name is not found, the %variableName% portion will be unchanged.

 

AGetEnvVariable [in, optional]

An optional environment variable converter.

 

There are overloads for procedural and method converter.

 

This function is used to get value of variables. You can supply your own converter to support more variables or change value of existsing ones.

 

If you don't specify this argument - the default converter will be used (GetEnvVariable).

 

Return value

ASource buffer with expanded environment variables.

 

Remarks

Expands environment-variable strings and replaces them with the values defined for the current user. You can override variables by supplying the second argument (AGetEnvVariable)

Tip

This function is similar to ExpandEnvironmentStrings.

 

Note

This routine is often replaced in EurekaLog classes to supply extra variables. For example, exception informational class adds support for %_ExceptMsg% variable.

 

 

Examples

 

Code (Delphi)

ExpandEnvVars('Windows dir: %WinDir%; non-existent var: %something%') =

'Windows dir: C:\Windows\; non-existent var: %something%'

 

See also

Environment variables



Send feedback... Build date: 2023-09-11
Last edited: 2023-09-11
PRIVACY STATEMENT
The documentation team uses the feedback submitted to improve the EurekaLog documentation. We do not use your e-mail address for any other purpose. We will remove your e-mail address from our system after the issue you are reporting has been resolved. While we are working to resolve this issue, we may send you an e-mail message to request more information about your feedback. After the issues have been addressed, we may send you an email message to let you know that your feedback has been addressed.


Permanent link to this article: https://www.eurekalog.com/help/eurekalog/topic_function_esysinfo_expandenvvars.php