Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How are Delphi 'environment variables' such as $(BDS) evaluated?

I'm making some tidy installers for our internal libraries (instead of just opening the DPK's and clicking 'install' and getting in a mess later...) and this has caused me to have to understand how to get at various Delphi variables such as Known Packages, the registry RootDir value etc.

I see that within Delphi there are a number of variables that you can use (within a search path for example) such as $(BDS) etc. When I look into my machine environment variables I dont see these, either in system or current user.

My questions are:

  1. Is Delphi doing something internal to expand $(BDS) etc itself? Or can I use these externally in some way (eg looked up in the registry).
  2. Why is the notation $(xxxx) within a search path and not %xxxx% as with an envirnment variable? Thanks
like image 538
Brian Frost Avatar asked Jul 29 '11 08:07

Brian Frost


People also ask

Where to find$( BDS?

The value for $(BDS) is found in: HKCU\Software\<Borcadero>\BDS\<version>\RootDir .

How do I select an environment variable?

On the Windows taskbar, right-click the Windows icon and select System. In the Settings window, under Related Settings, click Advanced system settings. On the Advanced tab, click Environment Variables. Click New to create a new environment variable.


1 Answers

1) They are simply environment variables which Delphi sets for its own process and you can retrieve them with GetEnvironmentStrings from a design package installed in the IDE; here's an example.

If your installer is a separate executable, you can still (more or less reliably) guess where to get some of the values:

  • BDS: RootDir value in the registry, e.g. HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\8.0\
  • BDSCOMMONDIR: in older versions (Delphi 2007, I guess) this was a global environment variable, set by the Delphi installer. In later versions you can find it in rsvars.bat.

Some others might probably be derived, e.g.:

  • BDSLIB: $(BDS)\lib
  • BDSINCLUDE: $(BDS)\include

User-defined variables (defined in Delphi's Environment Options dialog) are stored in the Environment Variables registry subkey.

2) The $(...) notation is IMHO simply better because it has distinct opening and closing delimiters, it's easier to work with for search/replace operations and also more readable.

like image 139
Ondrej Kelle Avatar answered Sep 30 '22 03:09

Ondrej Kelle