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

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

问题描述

我正在为我们的内部图书馆制作一些整洁的安装程序(而不是只打开DPK,点击安装,稍后会发生混乱),这使得我必须了解如何获得各种各样的内容Delphi变量,如已知软件包 ,注册表RootDir值等。



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



我的问题是:


  1. Delphi做一些内部扩展$( BDS)等?或者我可以以某种方式在外部使用(例如在注册表中查找)。

  2. 为什么搜索路径中的符号$(xxxx),而不是%xxxx%变量?
    谢谢


解决方案

1)他们只是Delphi为其设置的环境变量您可以使用 GetEnvironmentStrings 从安装在IDE中的设计包;这里是一个例子



如果您的安装程序是单独的可执行文件,您仍然可以(或多或少可靠)猜测在哪里可以获取一些值: / p>


  • BDS RootDir 注册表中的值,例如 HKEY_CURRENT_USER\SOFTWARE\Embarcadero\BDS\8.0\

  • BDSCOMMONDIR :在旧版本(Delphi 2007,我猜),这是一个全局环境变量,由Delphi安装程序设置。在以后的版本中,您可以在 rsvars.bat 中找到。



其他可能会导出,例如:




  • BDSLIB $(BDS)\lib

  • BDSINCLUDE $(BDS) \include



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



2) $(...)符号是IMHO更好,因为它有明确的打开和关闭分隔符,它更容易与搜索/替换操作,也更可读。


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

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

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