Delphi 如何评估 $(BDS) 等“环境变量"? [英] How are Delphi 'environment variables' such as $(BDS) evaluated?

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

问题描述

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

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

我的问题是:

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

解决方案

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

如果您的安装程序是一个单独的可执行文件,您仍然可以(或多或少可靠地)猜测从何处获取某些值:

  • BDS:注册表中的RootDir值,例如HKEY_CURRENT_USERSOFTWAREEmbarcaderoBDS8.0
  • BDSCOMMONDIR:在旧版本(我猜是 Delphi 2007)中,这是一个全局环境变量,由 Delphi 安装程序设置.在以后的版本中,您可以在 rsvars.bat 中找到它.

其他一些可能是派生的,例如:

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

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

2) 恕我直言,$(...) 符号更好,因为它具有不同的开始和结束分隔符,它更容易用于搜索/替换操作,也更易读.>

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

解决方案

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_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

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.

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆