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.
More information is available on the Environment Variables Unit Home Page.
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 and documentation are supplied in a zip file. Before installing you need to extract all the files from the zip file. The following files will be extracted:
PJEnvVars.pas – The Environment
Variables Unit. Contains all source code, including the deprecated
component, but excluding the component registration code.
PJEnvVars.dcr – Component palette glyph for the
deprecated component.
PJEnvVarsDsgn.pas – Registration code for the deprecated
component.
ReadMe.htm – This read-me file.
ChangeLog.txt – The project change log.
MPL-2.txt – The Mozilla Public License v2.0.
Documentation.url – Short-cut to the unit's online
documentation.
In addition to the above files you will find the source code for various demo projects in the Demos directory.
There are three possible ways to use the unit:
PJEnvVas.pas to your
projects whenever the unit is needed.
PJEnvVars.pas to a Delphi
package.
NOTE: None of the above methods will install the deprecated
component into the Delphi IDE. To do this you need to add
PJEnvVars.pas, PJEnvVars.dcr and
PJEnvVarsDsgn.pas to a design time package. If you need help
doing this see here. This is not recommended other than for reasons of backwards
compatibility.
The Environment Variables Unit has comprehensive online documentation.
In addition there is an article, How to access environment variables, that discusses interaction with environment variables on Windows.
Two different demo programs are includes 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.
A complete change log is provided in a text file that is included in the download.
The Environment Variables Unit is released under the terms of the Mozilla Public License v2.0.
Bugs can be reported or new features requested via the Issue Tracker.
If no similar report or request has been recorded already, use the New
Issue link to add a new issue. Please select the most appropriate
template from the Templates drop down list and make sure you specify
the Project-envvars label.
I'm Peter Johnson – a hobbyist programmer living in Ceredigion in West Wales, UK, writing write mainly in Delphi. My programs and code are available from http://www.delphidabbler.com/.
I can be contacted via the website.