Inno Setup ReadReg 运行时目标程序文件夹,添加 WAR 文件到 tomcat/webapps

问题描述

我想通过使用 Inno Setup 的 xampp\tomcat\webapps 功能查找 XAMPP 的 ReadReg 将 WAR 文件保存到 Install_Dir。这个问题类似于Inno Setup: read source path from a registry on compile time,但我认为我需要的答案是颠倒的。这是我所拥有的:

Source: "D:\Content.war"; \
  DestDir: "{#ReadReg(HKLM,"SOFTWARE\xampp","Install_Dir","DefaultDirName")}\tomcat\webapps"; \
  Flags: ignoreversion

但它不会将 WAR 文件保存到目标计算机的 XAMPP 文件夹中。请让我知道这应该如何正确地构建/编码。

解决方法

使用 scripted constantRegQueryStringValue function

[Files]
Source: "D:\Content.war"; DestDir: "{code:GetXamppPath}\tomcat\webapps"
[Code]

function GetXamppPath(Param: string): string;
begin
  RegQueryStringValue(HKLM,'SOFTWARE\xampp','Install_Dir',Result);
end;

尽管您还应该添加一些错误处理(特别是在没有这样的注册表项的情况下)。


顺便说一句,answer that you have based your script on 是正确的。但它确实,另一个问题所要求的:它在编译时读取密钥 = 在机器上构建它。那不是你想要的。