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

前端 未结 5 2174
梦谈多话
梦谈多话 2020-12-06 01:17

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

5条回答
  •  旧巷少年郎
    2020-12-06 01:48

    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.

提交回复
热议问题