inno-setup – Inno Setup有三个目标文件夹

前端之家收集整理的这篇文章主要介绍了inno-setup – Inno Setup有三个目标文件夹前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我需要创建一个简单的Inno安装程序安装程序,将三组不同的文件复制到C:或D:等的三个用户可选文件夹中.

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

我找到了一个脚本“提示输入数据的附加文件夹”,但下一页只有一个文件夹.

谢谢.

例如:

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

编辑:这是我得到的代码

  1. [Setup]
  2. AppName=MyProg
  3. AppVerName=MyProg
  4. DefaultDirName={pf}\MyProg
  5. DisableProgramGroupPage=yes
  6. UninstallDisplayIcon={app}\MyProg.exe
  7.  
  8. [Files]
  9. ;Main program that will be installed in {app} folder
  10. Source: MyProg.exe; DestDir: {app}
  11.  
  12. ;Database file that will installed where user choosed
  13. Source: DataBase.mdb; DestDir: {code:GetDataDir}
  1. [Code]
  2. var
  3. DataDirPage: TInputDirWizardPage;
  4.  
  5. procedure InitializeWizard;
  6. begin
  7. { Create the page }
  8.  
  9. 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,' +
  10. 'then click Next.',False,'');
  11. DataDirPage.Add('');
  12.  
  13. DataDirPage.Values[0] := GetPrevIoUsData('DataDir','');
  14. end;
  15.  
  16. procedure RegisterPrevIoUsData(PrevIoUsDataKey: Integer);
  17. begin
  18. { Store the selected folder for further reinstall/upgrade }
  19. SetPrevIoUsData(PrevIoUsDataKey,'DataDir',DataDirPage.Values[0]);
  20. end;
  21.  
  22. function NextButtonClick(CurPageID: Integer): Boolean;
  23. begin
  24. { Set default folder if empty }
  25. if DataDirPage.Values[0] = '' then
  26. DataDirPage.Values[0] := ExpandConstant('{sd}\DataDir');
  27. Result := True;
  28. end;
  29.  
  30. function UpdateReadyMemo(Space,NewLine,MemoUserInfoInfo,MemoDirInfo,MemoTypeInfo,MemoComponentsInfo,MemoGroupInfo,MemoTasksInfo: String): String;
  31. var
  32. S: String;
  33. begin
  34. { Fill the 'Ready Memo' with the normal settings and the custom settings }
  35. S := '';
  36.  
  37. S := S + MemoDirInfo + NewLine + NewLine;
  38.  
  39. S := S + 'Database path' + NewLine;
  40. S := S + Space + DataDirPage.Values[0] + NewLine;
  41.  
  42. Result := S;
  43. end;
  44.  
  45. function GetDataDir(Param: String): String;
  46. begin
  47. { Return the selected DataDir }
  48. Result := DataDirPage.Values[0];
  49. end;

解决方法

你可以写这样的东西:
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5.  
  6. [Files]
  7. ; the parameter passed to the GetDir function here is the index of a directory
  8. ; input page item,so the following 3 files will be installed each into one of
  9. ; the directories specified in the input page items
  10. Source: "File1.txt"; DestDir: "{code:GetDir|0}"
  11. Source: "File2.txt"; DestDir: "{code:GetDir|1}"
  12. Source: "File3.txt"; DestDir: "{code:GetDir|2}"
  1. [Code]
  2. var
  3. DirPage: TInputDirWizardPage;
  4.  
  5. function GetDir(Param: String): String;
  6. begin
  7. Result := DirPage.Values[StrToInt(Param)];
  8. end;
  9.  
  10. procedure InitializeWizard;
  11. begin
  12. { create a directory input page }
  13. DirPage := CreateInputDirPage(
  14. wpSelectDir,'Caption','Description','SubCaption','');
  15. { add directory input page items }
  16. DirPage.Add('Prompt 1');
  17. DirPage.Add('Prompt 2');
  18. DirPage.Add('Prompt 3');
  19. { assign default directories for the items from the prevIoUsly stored data; if }
  20. { there are no data stored from the prevIoUs installation,use default folders }
  21. { of your choice }
  22. DirPage.Values[0] := GetPrevIoUsData('Directory1','C:\HardcodedPath');
  23. DirPage.Values[1] := GetPrevIoUsData('Directory2',ExpandConstant('{userdocs}'));
  24. DirPage.Values[2] := GetPrevIoUsData('Directory3',ExpandConstant('{localappdata}'));
  25. end;
  26.  
  27. procedure RegisterPrevIoUsData(PrevIoUsDataKey: Integer);
  28. begin
  29. { store chosen directories for the next run of the setup }
  30. SetPrevIoUsData(PrevIoUsDataKey,'Directory1',DirPage.Values[0]);
  31. SetPrevIoUsData(PrevIoUsDataKey,'Directory2',DirPage.Values[1]);
  32. SetPrevIoUsData(PrevIoUsDataKey,'Directory3',DirPage.Values[2]);
  33. end;

要处理标准的“安装目录”,请参阅:
Use two/multiple selected directories from custom page in Files section

猜你在找的Delphi相关文章