«« Site Rescued »»

While the site is still going to move from its current host, a new site will now take its place. More Info.

The new site may have less content, but the core will now remain. And it will now play nicely with phones! Keep an eye on the DelphiDabbler Blog for news.

Environment Variables Unit

Release: 3.0.0
Date: 30 January 2014
Delphi Compatibility:
D1 D2 D3 D4 D5 D6 D7 D2005 D2006 D2007 D2009 D2010 DXE DXE2 DXE3 DXE4
Red LED Red LED Red LED Grey LED Grey LED Grey LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED Green LED

About the Unit


This unit provides a static class for reading and modifying the environment variables available to the current process, along with a class that can be used to enumerate environment variable names.

The unit also contains a component and a set of routines that duplicate some of the features provided by the static class. These are now deprecated and are provided for backward compatibility reasons only: they should no longer be used in new code.


The Environment Variables Unit has been tested on all Delphi versions from 7 to XE4, excluding Delphi 2005. The unit is thought to be compilable with versions of Delphi back to version 4, but this has not been tested.

The unit is compatible with both the Windows 32- and 64-bit Delphi compilers and the VCL and FireMonkey frameworks (tested with FireMonkey 2 only).

.NET and non-Windows platforms are not supported.


The Environment Variables Unit has comprehensive online documentation.

In addition, the unit is well documented with comments in XMLDoc format.

Demo Programs

Two different demo programs are included in the Demos\1 and Demos\2 sub-directories. There are VCL and FireMonkey 2 versions of each demo.

The demo programs are documented in the file DemosReadMe.htm that can be found in the Demos directory.

How it works

This unit uses ideas from my article "How to access environment variables". The article shows how to develop routines similar to some of those in this unit and discusses their operation.

Feedback & Queries

Please Note
It is a common mistake to believe that you can change Windows environment variables by altering them from your program using SetEnvironmentVariable. You can't. The section " A little background information" in the article noted above explains.
Please don't report this issue as a bug.

If you find any bugs or want to suggest a new feature please report them using the Issue Tracker.

Click the Create Ticket button to create a ticket then complete the form giving as much information as possible. Please note: this issue tracker is shared among all the projects in the DelphiDabbler Code Library, so please make sure you enter envvars in the Project edit box. You should also choose Defect in the Type drop down list to report a bug or Enhancement to request a new feature.

If you have created a bug fix or have implemented a new feature please attach a zip file to your ticket that contains your source code.

Should you have any queries about using the components please read the documentation.

If you can't find an answer in the documentation then post a message in the discussion group.

Please do not email me or use the contact page to report bugs, ask for new features or to find out how to use the unit.
I'm afraid I have very limited time available to support the code library, and can't guarantee I'll find time for personalised advice.