Home  |  Delphi .net Home  |  System.Environment  |  GetEnvironmentVariable Method
  
GetEnvironmentVariable  
Method  
Gets a single environment variable, by name
Environment Class
System NameSpace
NotCF1.  Function GetEnvironmentVariable ( Name : String ) : String; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns a single environment variable, by name.
 
The name must be be one of the following :
 
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
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
  userName, computerName : String;

begin
  // Display the computer name and user name
  userName     := Environment.GetEnvironmentVariable('USERNAME');
  computerName := Environment.GetEnvironmentVariable('COMPUTERNAME');

  Console.WriteLine('You are {0} logged on to {1}',
                    userName, computerName);

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