具有三个目标文件夹的Inno Setup [英] Inno Setup with three destination folders

查看:118
本文介绍了具有三个目标文件夹的Inno Setup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个简单的Inno Setup安装程序,以将三组不同的文件复制到C:或D:等的三个用户可选文件夹中.

I need to create a simple Inno Setup installer to copy three different sets of files to three user selectable folders for C: or D: etc,,.

这只是文件,没有应用程序.

This is just files only no application.

我确实找到了一个脚本提示输入另一个数据文件夹",但是下一页只有一个文件夹.

I did find one script "Prompt for an additional folder for data" but that only had one folder on the next page.

谢谢.

例如:

http://badjohnny.com.au/temp/myinno.jpg

这是我得到的代码:

[Setup]
AppName=MyProg
AppVerName=MyProg
DefaultDirName={pf}\MyProg
DisableProgramGroupPage=yes
UninstallDisplayIcon={app}\MyProg.exe

[Files]
;Main program that will be installed in {app} folder
Source: MyProg.exe; DestDir: {app}

;Database file that will installed where user choosed
Source: DataBase.mdb; DestDir: {code:GetDataDir}

[Code]
var
  DataDirPage: TInputDirWizardPage;

procedure InitializeWizard;
begin
  { Create the page }

  DataDirPage := CreateInputDirPage(wpSelectDir,
    'Select Personal Data Directory', 'Where should personal data files be installed?',
    'Select the folder in which Setup should install personal data files, ' +
      'then click Next.',
    False, '');
  DataDirPage.Add('');

  DataDirPage.Values[0] := GetPreviousData('DataDir', '');
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  { Store the selected folder for further reinstall/upgrade }
  SetPreviousData(PreviousDataKey, 'DataDir', DataDirPage.Values[0]);
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  { Set default folder if empty }
  if DataDirPage.Values[0] = '' then 
     DataDirPage.Values[0] := ExpandConstant('{sd}\DataDir');
  Result := True;
end;

function UpdateReadyMemo(Space, NewLine, MemoUserInfoInfo, MemoDirInfo, MemoTypeInfo,
  MemoComponentsInfo, MemoGroupInfo, MemoTasksInfo: String): String;
var
  S: String;
begin
  { Fill the 'Ready Memo' with the normal settings and the custom settings }
  S := '';

  S := S + MemoDirInfo + NewLine + NewLine;

  S := S + 'Database path' + NewLine;
  S := S + Space + DataDirPage.Values[0] + NewLine;

  Result := S;
end;

function GetDataDir(Param: String): String;
begin
  { Return the selected DataDir }
  Result := DataDirPage.Values[0];
end;

推荐答案

您可以编写如下内容:

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

[Files]
; the parameter passed to the GetDir function here is the index of a directory
; input page item, so the following 3 files will be installed each into one of
; the directories specified in the input page items
Source: "File1.txt"; DestDir: "{code:GetDir|0}"
Source: "File2.txt"; DestDir: "{code:GetDir|1}"
Source: "File3.txt"; DestDir: "{code:GetDir|2}"

[Code]
var
  DirPage: TInputDirWizardPage;

function GetDir(Param: String): String;
begin
  Result := DirPage.Values[StrToInt(Param)];
end;

procedure InitializeWizard;
begin
  { create a directory input page }
  DirPage := CreateInputDirPage(
    wpSelectDir, 'Caption', 'Description', 'SubCaption', False, '');
  { add directory input page items }
  DirPage.Add('Prompt 1');
  DirPage.Add('Prompt 2');
  DirPage.Add('Prompt 3');
  { assign default directories for the items from the previously stored data; if }
  { there are no data stored from the previous installation, use default folders }
  { of your choice }
  DirPage.Values[0] := GetPreviousData('Directory1', 'C:\HardcodedPath');
  DirPage.Values[1] := GetPreviousData('Directory2', ExpandConstant('{userdocs}'));
  DirPage.Values[2] := GetPreviousData('Directory3', ExpandConstant('{localappdata}'));
end;

procedure RegisterPreviousData(PreviousDataKey: Integer);
begin
  { store chosen directories for the next run of the setup }
  SetPreviousData(PreviousDataKey, 'Directory1', DirPage.Values[0]);
  SetPreviousData(PreviousDataKey, 'Directory2', DirPage.Values[1]);
  SetPreviousData(PreviousDataKey, 'Directory3', DirPage.Values[2]);
end;


要处理标准的安装目录",请参阅:
在文件"部分的自定义页面中使用两个/多个选定的目录


To deal with the standard "installation directory", see:
Use two/multiple selected directories from custom page in Files section

这篇关于具有三个目标文件夹的Inno Setup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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