Inno setup Inno设置:如何在InitializeWizard中使用{app}?

Inno setup Inno设置:如何在InitializeWizard中使用{app}?,inno-setup,Inno Setup,我知道几乎是同一个标题。但是Answare没有为我提供足够的信息来解决这个问题。我的问题也可能有点不同 我正在使用 我的消息来源看起来像 [Components] Name: "dl"; Description: "{cm:DLMessage}"; Types: full fullService Name: "dl\aaa"; Description: "aaa111"; Types: full fullService; Name: "dl\b

我知道几乎是同一个标题。但是Answare没有为我提供足够的信息来解决这个问题。我的问题也可能有点不同

我正在使用

我的消息来源看起来像

[Components]
Name: "dl";           Description: "{cm:DLMessage}";  Types: full fullService
Name: "dl\aaa";       Description: "aaa111";          Types: full fullService;
Name: "dl\bbb";       Description: "bbb222";          Types: full fullService;
Name: "dl\ccc";       Description: "ccc333";          Types: full fullService;

[Code]
procedure InitializeWizard();
begin
    idpAddFileComp('ftp://user:pass@server.xy/folder/myFile1.exe', ExpandConstant('{app}\subfolder\Download\myFile1.exe'), 'dl\aaa');
    idpAddFileComp('ftp://user:pass@server.xy/folder/myFile2.exe', ExpandConstant('{app}\subfolder\Download\myFile2.exe'), 'dl\bbb');
    idpAddFileComp('ftp://user:pass@server.xy/folder/myFile3.exe', ExpandConstant('{app}\subfolder\Download\myFile3.exe'), 'dl\ccc');
    idpDownloadAfter(wpReady);
end;
我想要实现的是根据组件的选择下载一些文件

因为我是新来的。。。答案

原型:

函数值:字符串

对我来说,就像你告诉牙医如何修理汽车一样:)

我想在初始值中使用
{app}
,但我没有一个clou how,即使有那个“提示”。有人能给我解释一下吗?(谷歌并没有真正帮助我)

事件方法是在向导表单创建后立即触发的,因此将
{app}
目录传递给插件还为时过早(
WizardDirValue
函数也会这样做),因为用户还没有传递目录输入页面。您需要将代码移动到一个事件中,该事件在用户选择目录后触发

请尝试以下方法:

[Setup]
AppName=My Program
AppVersion=1.5
DefaultDirName={pf}\My Program

[Code]
procedure InitializeWizard;
begin
  // only tell the plugin when we want to start downloading
  idpDownloadAfter(wpReady);
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  // if the user just reached the ready page, then...
  if CurPageID = wpReady then
  begin
    // because the user can move back and forth in the wizard, this code branch can
    // be executed multiple times, so we need to clear the file list first
    idpClearFiles;
    // and add the files to the list; at this time, the {app} directory is known
    idpAddFileComp('ftp://user:pass@server.xy/folder/myFile1.exe', ExpandConstant('{app}\subfolder\Download\myFile1.exe'), 'dl\aaa');
    idpAddFileComp('ftp://user:pass@server.xy/folder/myFile2.exe', ExpandConstant('{app}\subfolder\Download\myFile2.exe'), 'dl\bbb');
    idpAddFileComp('ftp://user:pass@server.xy/folder/myFile3.exe', ExpandConstant('{app}\subfolder\Download\myFile3.exe'), 'dl\ccc');
  end;
end;

InitializeWizard
事件方法在创建向导表单后立即触发,因此传递
{app}
目录(或调用
wizardirvalue
函数,实际上也是这样)为时过早,因为用户尚未通过目录输入页面。您需要将此代码移动到一个事件中,该事件在用户选择目录后触发。尝试另外,可以调用
WizardDirValue
而不是展开
{app}
常量,例如
S:=ExpandConstant('{app}')
可替换为
S:=WizardDirValue
@TLama这是你第二次给我一个非常棒的答案,并用第一次打击解决了它!你能帮我个忙吗?能帮我把这封信寄到一个邮箱里吗?我真的想给你提供一些观点:)好的,让我们删除我们的评论:)