Since I work on several projects that require multiple Delphi installations, I needed a way to start the correct Delphi IDE and call the correct command line compiler for each of these projects. There apparently is no way to automatically detect the Delphi version from the .dof,.dpr or .dproj file (or at least this is limited), so I added batch files to these projects that call the correct Delphi version.

Since I work on several projects that require multiple Delphi installations, I needed a way to start the correct Delphi IDE and call the correct command line compiler for each of these projects. There apparently is no way to automatically detect the Delphi version from the .dof,.dpr or .dproj file (or at least this is limited), so I added batch files to these projects that call the correct Delphi version.

One of the things that irked me was that I had to adapt these batch files whenever I was working on a different computer and Delphi was not installed in the default installation directory. Finally I found a solution for this: The required information is stored in the registry at

HKCU\Software\(Borland|CodeGear|Embaracdero)\(TheDelphiVersion)\root

And the place where this is stored does not vary. I set out to find a way to read the registry from a batch file and found this answer on stackoverflow.

So, here is the result. A batch file that, when called with a Delphi version as parameter, returns the directory it is installed in:
http://blog.dummzeuch.de/2014/04/17/determine-the-delphi-installation-directory-from-a-batch-file/

Comments

  1. I made some work on this area, check this unit http://code.google.com/p/delphi-dev-shell-tools/source/browse/trunk/units/uDelphiVersions.pas which include some classes to detect the Delphi ide version from a .dproj file, the current active configuration (Debug, Release) and platform (Win32, Win64, Android, OSX) and another useful information.

    ReplyDelete
  2. Note that sometimes (I've not tracked down yet when) the information is in HKLM, not HKCU.

    ReplyDelete
  3. I think it's the other way round: The information is always in HKCU, but only sometimes in HKLM.

    ReplyDelete
  4. I think that depends if your machine has different users using Delphi or not. Need to dig into this deeper some day.

    ReplyDelete
  5. FYI; I haven't played with this issue. But thought I'd mention that... 32-bit apps (delphi) on a 64-bit platform will have HKLM redirected to a subkey called "Wow6432Node"

    ReplyDelete
  6. I just pushed a new version of that script.

    ReplyDelete
  7. From my experience, the registry key is in HKLM after installation, and it gets copied to HKCU when you start IDE from a user account if it doesn't already exist. (If you delete it from HKCU it will be copied again from HKLM.)

    ReplyDelete
  8. Ondrej Kelle Thanks, that makes a lot of sense.

    ReplyDelete

Post a Comment