Path Size with Multiple versions of Delphi

I work on a variety of projects in several different versions of both Delphi and Visual Studio. A lot of these projects also include database access. To support all these different projects, a lot of different tools need to be installed and with each comes a set of paths that are setup for the applications to find libraries, support tools, and so forth. Since most software tools can also generate both 32-bit and 64-bit code these days, there are often two sets of paths for each type of compilation.

Recently, as I was installing my 6th version of Delphi on a new laptop, I encountered the warning that my PATH environment variable was reaching it's length limit. Sure enough, when I edited it from the System Control Panel, it also warned me that the PATH environment variable was too long--the dialog only allows values up to 2,047 characters long.

Since I had a few more versions to install, I had to make a work-around. I discovered this trick when I installed a Developer Express library a while back and saw how it shortened it's very long path to just another variable. First, it created the variable,
DXVCL=C:\Program Files (x86)\DevExpress.VCL

Then when it needed to add a PATH for it, it simply added this value: %DXVCL%\Library\Delphi15 instead of the full path.

A light-bulb came on in my head when I saw that and I thought, "if Dev Express can do it, why can't I?" I noticed Delphi was being installed in the base path, C:\Program Files (x86)\Embarcadero and that compiled packages were being added to paths under C:\Users\David\Documents\Embarcadero\Studio. So I created a couple of environment variables:

  • EMB=C:\Program Files (x86)\Embarcadero
  • EMB_USER=C:\Users\David\Documents\Embarcadero\Studio

Now, my path entries look like this:

When I finished, I had 3 versions of Visual Studio (2013, 2015, and 2017) and 10 different versions of Delphi installed (from Delphi 7 to Delphi 10.2 Tokyo), all one one Windows 10 machine!