Home  |  Delphi .net Home  |  System.Environment  |  GetEnvironmentVariables Method
  
GetEnvironmentVariables  
Method  
Gets the environment variables for the current process
Environment Class
System NameSpace
NotCF1.  Function GetEnvironmentVariables : IDictionary; Static;
CF : Methods with this mark are Compact Framework Compatible
Description
Returns an IDictionary object containing the environment information as a set of key/value data pairs.
 
The key values are as follows :
 
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
References
IDictionary
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}

uses
  System.Collections;

var
  envVars    : IDictionary;
  enumerator : IDictionaryEnumerator;

  i          : Integer;

begin
  // Get the environment variables
  envVars := System.Environment.GetEnvironmentVariables;

  // Display each variable name and value
  enumerator := envVars.GetEnumerator;

  for i := 0 to envVars.Count-1 do
  begin
    enumerator.MoveNext;
    Console.WriteLine('{0} = {1}',
                      enumerator.Key.ToString,
                      enumerator.Value.ToString);
  end;

  Console.ReadLine;
end.
   USERPROFILE = C:\Documents and Settings\Neil
   DBROOT = C:\Adabas
   DBCONFIG = C:\Adabas\sql
   INCLUDE = C:\PROGRA~1\hts40\ostore\INCLUDE;
   Path = C:\Program Files\Common Files\Borland Shared\BDE\;C:\Program Files\Borlan
   d\BDS\2.0\Bin;C:\PROGRA~1\hts40\ostore\BIN;C:\Program Files\Borland\Delphi7\Bin;
   C:\Program Files\Borland\Delphi7\Projects\Bpl\;C:\WINDOWS\system32;C:\WINDOWS;C:
   \WINDOWS\System32\Wbem;C:\Program Files\Microsoft SQL Server\80\Tools\BINN;C:\Pr
   ogram Files\Symantec\pcAnywhere\;C:\Program Files\Common Files\GTK\2.0\bin;C:\Ad
   abas\bin;C:\Adabas\pgm
   TMP = C:\DOCUME~1\Neil\LOCALS~1\Temp
   LOGONSERVER = \\DEVELOPMENT
   PROCESSOR_ARCHITECTURE = x86
   DBWORK = C:\Adabas\sql
   ProgramFiles = C:\Program Files
   NUMBER_OF_PROCESSORS = 1
   CommonProgramFiles = C:\Program Files\Common Files
   SystemDrive = C:
   APPDATA = C:\Documents and Settings\Neil\Application Data
   ComSpec = C:\WINDOWS\system32\cmd.exe
   BDS = c:\program files\borland\bds\2.0
   HOMEDRIVE = C:
   COMPUTERNAME = DEVELOPMENT
   PROCESSOR_LEVEL = 15
   OS = Windows_NT
   Cor_Debugging_Control_424242 = 1
   PROCESSOR_IDENTIFIER = x86 Family 15 Model 2 Stepping 7, GenuineIntel
   windir = C:\WINDOWS
   USERDOMAIN = DEVELOPMENT
   ALLUSERSPROFILE = C:\Documents and Settings\All Users
   USERNAME = Neil
   PATHEXT = .COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
   CLIENTNAME = Console
   HOMEPATH = \Documents and Settings\Neil
   SystemRoot = C:\WINDOWS
   TEMP = C:\DOCUME~1\Neil\LOCALS~1\Temp
   LIB = C:\PROGRA~1\hts40\ostore\LIB;
   PROCESSOR_REVISION = 0207
   SESSIONNAME = Console
   OS_ROOTDIR = C:\PROGRA~1\hts40\ostore
   OS_TMPDIR = C:\WINDOWS\TEMP
 
 
Delphi Programming Neil Moffatt 2002 - 2017. All rights reserved.  |  Contact the author