Inno Setup:如何在InitializeWizard中使用{app}?

时间:2015-05-07 11:53:50

标签: inno-setup

我知道this question was asked before的标题几乎相同。但回答并没有为我提供足够的信息来解决问题。我的问题接缝也有点不同。

我正在使用Inno Download Plugin

My Source看起来像

[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;

我想要实现的是根据使用组件做出的选择来下载一些文件。

因为即时通讯相对较新,所以...回答

  

原型:

     
    

function WizardDirValue:String;

  

对我说同样的,如果你试着告诉牙医如何修车:)

我想在InitializeWizard中使用{app},但我没有一个clou如何,即使给出了“提示”。有人可以向我解释一下吗? (谷歌并没有真正帮助我)

1 个答案:

答案 0 :(得分:3)

创建向导表单后立即触发InitializeWizard事件方法,因此将{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;