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:
- 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).
- Why is the notation $(xxxx) within a search path and not %xxxx% as with an envirnment variable?
Thanks
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:RootDirvalue 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 inrsvars.bat.Some others might probably be derived, e.g.:
BDSLIB:$(BDS)\libBDSINCLUDE:$(BDS)\includeUser-defined variables (defined in Delphi’s Environment Options dialog) are stored in the
Environment Variablesregistry 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.