Home  |  Delphi .net Home  |  System.Environment  |  ExpandEnvironmentVariables Method
  
ExpandEnvironmentVariables  
Method  
Inserts environment variables into a string containing placeholders
Environment Class
System NameSpace
NotCF1.  Function ExpandEnvironmentVariables ( Format : String ) : String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
The ExpandEnvironmentVariables method takes a Format string as argument that contains environment variable placeholder strings within. It returns a version of the string with the placeholders replaced by environment values.
 
The placeholders have the following syntax :
 
%Name%
 
Where Name can be any of the following values :
 
ALLUSERSPROFILE
APPDATA
BDS
CLIENTNAME
CommonProgramFiles
COMPUTERNAME
ComSpec
Cor_Debugging_Control_424242
DBCONFIG
DBROOT
DBWORK
HOMEDRIVE
HOMEPATH
INCLUDE
LIB
LOGONSERVER
NUMBER_OF_PROCESSORS
OS_ROOTDIR
OS_TMPDIR
OS
Path
PATHEXT
PROCESSOR_ARCHITECTURE
PROCESSOR_IDENTIFIER
PROCESSOR_LEVEL
PROCESSOR_REVISION
ProgramFiles
SESSIONNAME
SystemDrive
SystemRoot
TEMP
TMP
USERDOMAIN
USERNAME
USERPROFILE
windir
Notes
Static methods are not methods of an object - they are simply class functions or procedures available at any time.
Microsoft MSDN Links
System
System.Environment
 Author links

 Buy Website Traffic at
 Buywebsitetrafficexperts.com

 Buy Proxies at
 Buyproxies.io
 
 
 
A simple example
program Project1;
{$APPTYPE CONSOLE}

var
  formatStr, resultStr : String;

begin
  // Display the computer name and user name
  formatStr := 'You are %USERNAME% logged on to %COMPUTERNAME%';
  resultStr := System.Environment.ExpandEnvironmentVariables(formatStr);

  // Display the resulting built string
  Console.WriteLine(resultStr);

  Console.ReadLine;
end.
   You are Neil logged on to DEVELOPMENT
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author