本文介绍了如何评估 $(BDS) 等 Delphi 的“环境变量"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我们的内部库制作一些整洁的安装程序(而不是仅仅打开 DPK 并单击安装"然后一团糟……)这使我不得不了解如何在各种Delphi 变量,例如 Known Packages, 注册表 RootDir 值等.

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.

我看到在 Delphi 中有许多变量可以使用(例如在搜索路径中),例如 $(BDS) 等.当我查看我的机器环境变量时,我在系统中都没有看到这些变量或当前用户.

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.

我的问题是:

  1. Delphi 是否在内部做一些事情来扩展 $(BDS) 等本身?或者我可以以某种方式在外部使用这些(例如在注册表中查找).
  2. 为什么在搜索路径中使用符号 $(xxxx) 而不是环境变量中的 %xxxx%?谢谢

推荐答案

1) 它们只是Delphi为自己的进程设置的环境变量,你可以通过GetEnvironmentStrings 来自安装在 IDE 中的设计包;这是 一个例子.

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值,例如HKEY_CURRENT_USERSOFTWAREEmbarcaderoBDS8.0
  • BDSCOMMONDIR:在旧版本中(我猜是 Delphi 2007),这是一个全局环境变量,由 Delphi 安装程序设置.在以后的版本中,您可以在 rsvars.bat 中找到它.
  • BDS: RootDir value in the registry, e.g. HKEY_CURRENT_USERSOFTWAREEmbarcaderoBDS8.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

用户定义的变量(在 Delphi 的环境选项对话框中定义)存储在 Environment Variables 注册表子项中.

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

2) 恕我直言,$(...) 表示法更好,因为它具有不同的开始和结束分隔符,它更易于用于搜索/替换操作并且更具可读性.

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.

这篇关于如何评估 $(BDS) 等 Delphi 的“环境变量"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 08:31