论坛风格切换切换到宽版
  • 18575阅读
  • 25回复

[INNO 示例脚本] 如何创建带外部文件的安装程序 [复制链接]

上一主题 下一主题

发帖
34
金钱
0
威望
0
只看该作者 10 发表于: 2007-05-24
老虎兄-为啥我做的可选安装总带着哪个上边的选择框呢?就是哪个-完全安装、讲解安装、自定义安装的-

你的这个不带

一般的如何去掉它们呢
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 11 发表于: 2007-05-25
QUOTE(wangwei.hebtu @ 2007年 05月 24日 22时 29分) [snapback]332878[/snapback]

老虎兄-为啥我做的可选安装总带着哪个上边的选择框呢?就是哪个-完全安装、讲解安装、自定义安装的-

你的这个不带

一般的如何去掉它们呢

WizardForm.TYPESCOMBO.Visible:= false;
WizardForm.ComponentsList.Height := WizardForm.ComponentsList.Height + WizardForm.ComponentsList.Top - WizardForm.TYPESCOMBO.Top;
WizardForm.ComponentsList.Top := WizardForm.TYPESCOMBO.Top;

参看帖子:
http://bbs.hanzify.org/read.php?tid=52765

发帖
34
金钱
0
威望
0
只看该作者 12 发表于: 2007-05-25
学到了-谢谢!
离线4231252

发帖
23
金钱
230
威望
23
只看该作者 13 发表于: 2012-08-23
一定要学习,
在其他地方看到老虎哥的回复真的是不厌其烦啊,
如今真的很难有这种有耐心的高手了
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 14 发表于: 2013-03-31
外部文件是 7zip 格式的代码。使用了 is7z.dll 插件,可以在进度条显示解压进度。
  1. ; Inno Setup 脚本
  2. ; 该示例脚本显示如何创建的带外部文件的安装程序。运行安装程序时用户可以根据外部文件存在的情况选择安装相应的组件。
  3. ; 外部文件保存在安装程序所的目录中,外部文件是 7ZIP 压缩文件,命名为 data1.dat、data2.dat 等等
  4. ; 分别相应于组件 1、组件 2 等等。
  5. ;
  6. ; 汉化新世纪 gnatix 于 2013.03.31
  7. [Setup]
  8. AppName=组件安装示例程序
  9. AppVerName=组件安装示例程序 2.0
  10. DefaultDirName={pf}\_组件安装示例程序
  11. DefaultGroupName=组件安装示例程序
  12. [Messages]
  13. ComponentsDiskSpaceMBLabel=
  14. [Files]
  15. ; 安装临时文件:解压外部文件所需的插件 is7z.dll
  16. Source: is7z.dll; Flags: dontcopy
  17. ; 安装运行软件所必需的文件
  18. Source: "MyProg.exe"; DestDir: "{app}"; components: installmust
  19. Source: "MyProg.hlp"; DestDir: "{app}"; components: installmust
  20. [Components]
  21. Name: "installmust"; Description: "主程序(必需)"; Types: compact full custom; Flags: fixed
  22. Name: "installdata1"; Description: "组件 1 (常用插件)"; Types: full custom
  23. Name: "installdata2"; Description: "组件 2 (高级插件)"; Types: full custom
  24. [UninstallDelete]
  25. ; 卸载时删除外部解压的文件
  26. Type: filesandordirs; Name: "{app}\data1"
  27. Type: filesandordirs; Name: "{app}\data2"
  28. [Code]
  29. var
  30.   data1exists, data2exists: boolean;
  31. // 从 is7z.dll 插件中要调用的函数
  32. procedure Extract7z(hWnd, hpb, hst: THandle; fpath, extractPath, pass:PAnsiChar); external 'Extract7z@files:is7z.dll stdcall';
  33. procedure CancelExtract; external 'CancelExtract@files:is7z.dll stdcall';
  34. // 点击组件列表后刷新显示的内容
  35. procedure ComponentsListOnClick(Sender: TObject);
  36. begin
  37.   if not data1exists then
  38.     WizardForm.ComponentsList.ITEMSUBITEM[1]:= '无数据文件可用';
  39.   if not data2exists then
  40.     WizardForm.ComponentsList.ITEMSUBITEM[2]:= '无数据文件可用';
  41. end;
  42. // 初始化安装向导
  43. procedure InitializeWizard();
  44. begin
  45.   WizardForm.TYPESCOMBO.Visible:= false;
  46.   WizardForm.ComponentsList.Onclick:= @ComponentsListOnClick;
  47.   // 根据外部文件存在的情况确定哪些组件可用
  48.   data1exists := FileExists(ExpandConstant('{src}\data1.dat'));
  49.   data2exists := FileExists(ExpandConstant('{src}\data2.dat'));
  50.   WizardForm.ComponentsList.ITEMENABLED[1]:= data1exists;
  51.   WizardForm.ComponentsList.CHECKED[1]:= data1exists;
  52.   if not data1exists then
  53.     WizardForm.ComponentsList.ITEMSUBITEM[1]:= '无数据文件可用';
  54.   WizardForm.ComponentsList.ITEMENABLED[2]:= data2exists;
  55.   WizardForm.ComponentsList.CHECKED[2]:= data2exists;
  56.   if not data2exists then
  57.     WizardForm.ComponentsList.ITEMSUBITEM[2]:= '无数据文件可用';
  58. end;
  59. // 根据组件选择的情况从外部文件中解压组件到指定的位置,比如子目录 {app}\data1 和 {app}\data2
  60. procedure CurStepChanged(CurStep: TSetupStep);
  61. begin
  62.     if CurStep=ssPostInstall then
  63.     begin
  64.       if IsComponentSelected('installdata1') then
  65.         begin
  66.         WizardForm.StatusLabel.Caption:= '正在安装组件 1 的文件,请稍候...';
  67.         try
  68.           Extract7z (wizardform.handle, WizardForm.ProgressGauge.handle, WizardForm.FileNameLabel.handle, ExpandConstant('{src}\data1.dat'), ExpandConstant('{app}\data1'), 'mypass');    // 最后这个参数是它的解压密码
  69.         except
  70.           MsgBox('密码错误!', mbInformation, MB_OK);
  71.         end;
  72.         end;
  73.       if IsComponentSelected('installdata2') then
  74.         begin
  75.         WizardForm.StatusLabel.Caption:= '正在安装组件 2 的文件,请稍候...';
  76.         try
  77.           Extract7z (wizardform.handle, WizardForm.ProgressGauge.handle, WizardForm.FileNameLabel.handle, ExpandConstant('{src}\data2.dat'), ExpandConstant('{app}\data2'), 'mypass');    // 最后这个参数是它的解压密码
  78.         except
  79.           MsgBox('密码错误!', mbInformation, MB_OK);
  80.         end;
  81.         end;
  82.     end;
  83. end;


离线axlswd

发帖
95
金钱
910
威望
91
只看该作者 15 发表于: 2013-04-04
请问虎版 UNZIPW32.DLL 能像is7z.dll 那样支持解压密码吗?如果可以的话怎样添加代码?劳烦了!
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 16 发表于: 2013-04-04
UNZIPW32.DLL 没有 is7z.dll 那样的功能,比如它不能和安装程序的进度条联系起来。

如果你只是为了解压带密码的 7zip 文件,可以参考这里:
http://bbs.hanzify.org/read-htm-tid-97135.html
离线969511048

发帖
151
金钱
1440
威望
144
只看该作者 17 发表于: 2014-05-18
先收藏
离线solan

发帖
80
金钱
800
威望
80
只看该作者 18 发表于: 2015-12-15
请问:虎版提到的支持安装进度条的is7z.dll插件在哪儿下载,我在网上一直搜不到啊
离线gnatix

发帖
7696
金钱
-8279
威望
-828
只看该作者 19 发表于: 2015-12-17
回 18楼(solan) 的帖子
solan:请问:虎版提到的支持安装进度条的is7z.dll插件在哪儿下载,我在网上一直搜不到啊 (2015-12-15 21:01) 

http://forum.ru-board.com:9000/topic.cgi?forum=5&topic=46338&start=0&limit=1&m=4