首页 技术 正文
技术 2022年11月22日
0 收藏 716 点赞 4,102 浏览 7655 个字

一个比较完整的Inno Setup 安装脚本,增加了对ini文件设置的功能,一个安装包常用的功能都具备了。

  1. [Setup]
  2. ; 注: AppId的值为单独标识该应用程序。
  3. ; 不要为其他安装程序使用相同的AppId值。
  4. ; (生成新的GUID,点击 工具|在IDE中生成GUID。)
  5. AppId={{A9861883-31C5-4324-BD9A-DC3271EEB675}
  6. ;程序名
  7. AppName=ISsample
  8. ;版本号
  9. AppVerName=ISsample 1.0.0.0
  10. ;发布者名
  11. AppPublisher=Hkiss
  12. ;相关连接
  13. AppPublisherURL=http://zwkufo.blog.163.com
  14. AppSupportURL=http://zwkufo.blog.163.com
  15. AppUpdatesURL=http://zwkufo.blog.163.com
  16. ;默认安装目录
  17. DefaultDirName={pf}\ISsample
  18. ;默认开始菜单名
  19. DefaultGroupName=ISsample
  20. ;是否打开->可选安装开始菜单项
  21. ;AllowNoIcons=yes
  22. ;安装协议
  23. ;LicenseFile=C:\Example\原始文件\agreement.txt
  24. ;安装前查看的文本文件
  25. ;InfoBeforeFile=C:\Example\原始文件\Setup_New.txt
  26. ;安装后查看文本文件
  27. ;InfoAfterFile=C:\Example\原始文件\Setup_Old.txt
  28. ;输出文件夹
  29. OutputDir=C:\Example\InnoSetup\out
  30. ;输出文件名
  31. OutputBaseFilename=setup
  32. ;安装图标
  33. SetupIconFile=C:\Example\原始文件\title.ico
  34. ;安装需要输入密码
  35. ;Password=123
  36. ;Encryption=yes
  37. ;压缩相关
  38. Compression=lzma
  39. SolidCompression=yes
  40. ;可以让用户忽略选择语言相关
  41. ShowLanguageDialog = yes
  42. ;备注版本信息
  43. VersionInfoCompany=HTTP://www.Hkiss.COM
  44. VersionInfoDescription=ISsample 汉化增强版
  45. VersionInfoVersion=1.0.0.0
  46. VersionInfoCopyright=Copyright (C) 2007-2008 Hkiss
  47. ;制作选择语言
  48. [Languages]
  49. Name: “chs”; MessagesFile: “compiler:Default.isl” ;LicenSeFile :”C:\Example\原始文件\chs\agreement.txt”
  50. Name: “en”; MessagesFile: “compiler:Languages\English.isl”;LicenSeFile :”C:\Example\原始文件\en\agreement.txt”
  51. ;用户定制任务
  52. [Tasks]
  53. Name: “desktopicon”; Description: “{cm:CreateDesktopIcon}”; GroupDescription: “{cm:AdditionalIcons}”; Flags: unchecked
  54. Name: “quicklaunchicon”; Description: “{cm:CreateQuickLaunchIcon}”; GroupDescription: “{cm:AdditionalIcons}”; Flags: unchecked
  55. Name: “Tasks_1″ ; Description:”用户自定义任务1”; Flags: unchecked
  56. Name: “Tasks_2″ ; Description:”用户自定义任务2”; Flags: unchecked
  57. ;选择了组件才会出现的定制任务
  58. Name: “Tasks_3″ ; Description:”用户自定义任务3”;Components: c1 ; Flags: unchecked
  59. ;文件安装
  60. [Files]
  61. ;多语言安装环境设置    公共参数Languages 来设置
  62. Source: “C:\Example\原始文件\enfile.txt”; DestDir: “{app}”; Languages: en ; Flags: ignoreversion
  63. Source: “C:\Example\原始文件\chsfile.txt”; DestDir: “{app}”; Languages: chs ; Flags: ignoreversion
  64. ;用户自定义任务 Tasks
  65. Source: “C:\Example\原始文件\Tasks\tasks_1.txt”; DestDir: “{app}\Tasks”; Flags: ignoreversion ;Tasks : Tasks_1
  66. Source: “C:\Example\原始文件\Tasks\tasks_2.txt”; DestDir: “{app}\Tasks”; Flags: ignoreversion ;Tasks :Tasks_2
  67. Source: “C:\Example\原始文件\Tasks\tasks_Components.txt”; DestDir: “{app}\Tasks”; Flags: ignoreversion ;Tasks :Tasks_2
  68. ;用户定义组件安装
  69. Source: “C:\Example\原始文件\Components\Components_1.txt”; DestDir: “{app}\Components”; Flags: ignoreversion ; Components: a1;
  70. Source: “C:\Example\原始文件\Components\Components_2.txt”; DestDir: “{app}\Components”; Flags: ignoreversion ; Components: a2;
  71. Source: “C:\Example\原始文件\Components\Components_3.txt”; DestDir: “{app}\Components”; Flags: ignoreversion ; Components: a3;
  72. Source: “C:\Example \原始文件\Components\Components_4.txt”; DestDir: “{app} \Components”; Flags: ignoreversion ; Components: a1 a2 a3;
  73. ;用户注册自定义Dll文件      regserver 注册 noregerror 不显示错误信息
  74. Source: “C:\Example\原始文件\jmail.dll”; DestDir: “{app}”; Flags: ignoreversion regserver
  75. ;添加自述文件
  76. Source: “C:\Example\原始文件\ISsample.txt”; DestDir: “{app}”; Flags: ignoreversion
  77. ;添加一个文件到缓存文件夹{Tmp} deleteafterinstall 安装后删除
  78. Source: “C:\Example\原始文件\test.exe”; DestDir: “{tmp}”; Flags: ignoreversion deleteafterinstall
  79. Source: “C:\Example\原始文件\ISsample.chm”; DestDir: “{app}”; Flags: ignoreversion
  80. Source: “C:\Example\原始文件\ISsample.exe”; DestDir: “{app}”; Flags: ignoreversion
  81. Source: “C:\Example\原始文件\ISsample.dll”; DestDir: “{app}”; Flags: ignoreversion
  82. Source: “C:\Example\原始文件\ISsample.ini”; DestDir: “{app}”; Flags: ignoreversion
  83. Source: “C:\Example\原始文件\ISsample.rar”; DestDir: “{app}”; Flags: ignoreversion
  84. Source: “C:\Example\原始文件\ISsample_sys.dll”; DestDir: “{win}\System32”; Flags: ignoreversion
  85. Source: “C:\Example\原始文件\log\*”; DestDir: “{app}\log”; Flags: ignoreversion recursesubdirs createallsubdirs
  86. ; 注意: 不要在任何共享系统文件上使用“Flags: ignoreversion”
  87. ;安装类型设置
  88. [Types]
  89. Name: Full ;Description:”完全安装”; Flags: iscustom
  90. Name: Compact ;Description:”简洁安装”;
  91. Name: Custom; Description:”自定义安装”;
  92. ;组件安装
  93. [Components]
  94. Name: c1; Description: “自定义任务3” ; Types: Full
  95. Name: a1; Description: “安装Components_1”; Types: Full Compact Custom ;
  96. Name: a2; Description: “安装Components_2”; Types : Full   Compact
  97. Name: a3; Description: “安装Components_3”; Types : Full
  98. ;开始菜单,桌面快捷方式
  99. [Icons]
  100. Name: “{group}\ISsample”; Filename: “{app}\ISsample.exe”
  101. Name: “{group}\{cm:ProgramOnTheWeb,ISsample}”; Filename: “http://zwkufo.blog.163.com”
  102. Name: “{group}\{cm:UninstallProgram,ISsample}”; Filename: “{uninstallexe}”
  103. Name: “{commondesktop}\ISsample”; Filename: “{app}\ISsample.exe”; Tasks: desktopicon
  104. Name: “{userappdata}\Microsoft\Internet Explorer\Quick Launch\ISsample”; Filename: “{app}\ISsample.exe”; Tasks: quicklaunchicon
  105. ;添加一个帮助文挡
  106. Name: {group}\ISsample 1.0.0.0 帮助文档;Filename: {app}\ISsample.chm
  107. ;用来在程序安装完成后 在安装程序显示最终对话框之前执行程序 常用与运行主程序 显示自述文件 删除临时文件
  108. [Run]
  109. Filename: “{app}\ISsample.exe”; Description: “{cm:LaunchProgram,ISsample}”; Flags: nowait postinstall skipifsilent
  110. Filename: “{app}\ISsample.txt”; Description: “查看显示自述文件”; Flags: postinstall skipifsilent shellexec
  111. ;更改显示在程序中显示的消息文本
  112. [Messages]
  113. BeveledLabel=HKiss科技
  114. ;卸载对话框说明
  115. ConfirmUninstall=您真的想要从电脑中卸载ISsample吗?%n%n按 [是] 则完全删除 %1 以及它的所有组件;%n按 [否]则让软件继续留在您的电脑上.
  116. ;定义解压说明
  117. ;StatusExtractFiles=解压并复制主程序文件及相关库文件…
  118. ;用于在用户系统中创建,修改或删除ini文件健值
  119. [INI]
  120. Filename: “{app}\cfg.ini”; Section: “Startup Options”; Flags: uninsdeletesection
  121. Filename: “{app}\cfg.ini”; Section: “Startup Options”; Key: “server ip”; String: “127.0.0.1”
  122. Filename: “{app}\cfg.ini”; Section: “Startup Options”; Key: “server port”; String: “8080”
  123. ;用于在用户系统中创建,修改或删除注册表健值
  124. [Registry]
  125. Root: HKLM ;SubKey:”Software\ISsample”;ValueType:dword;ValueName:config;ValueData:10 ;Flags:uninsdeletevalue
  126. ;在执行脚本
  127. [code]
  128. //全局变量
  129. var MyProgChecked: Boolean;
  130. //判断程序是否存在
  131. //初始华程序事件
  132. function InitializeSetup(): boolean;
  133. var Isbl: boolean;         //声明变量
  134. var Isstr: string;
  135. begin       //开始
  136. Isbl := true;             //变量赋值
  137. Isstr := ‘欢迎’;
  138. if RegValueExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\ISsample’, ‘config’) then
  139. begin
  140. MsgBox(‘已安装过,请先卸载在安装’,mbConfirmation, MB_OK);
  141. isbl := false;
  142. end else
  143. begin
  144. //MsgBox(‘无值’,mbConfirmation, MB_OK);
  145. isbl := true;
  146. end;
  147. //下面是个麻烦的 条件语句 end else 注意
  148. //if MsgBox(Isstr, mbConfirmation, MB_OKCANCEL) = IDOK then
  149. //begin
  150. // isbl := true;
  151. // MsgBox(‘执行了’, mbConfirmation, MB_OK);
  152. //end else
  153. //begin
  154. // isbl := false;
  155. //MsgBox(‘执行了’, mbConfirmation, MB_OK);
  156. //end;
  157. Result := Isbl;
  158. end;       //结束
  159. procedure CurStepChanged(CurStep: TSetupStep);
  160. var Isstr :string;
  161. begin
  162. if CurStep=ssInstall then       //实际安装前调用
  163. begin
  164. //MsgBox(‘CurStepChanged:实际安装前调用’, mbConfirmation, MB_OKCANCEL);           //安装完成后调用
  165. end;
  166. if CurStep=ssPostInstall then
  167. begin
  168. Isstr := ExpandConstant(‘{tmp}\tmp.rar’);
  169. //    if FileExists(Isstr) then
  170. //    begin
  171. //      MsgBox(‘文件存在’,mbConfirmation, MB_OK);
  172. //    end else
  173. //    begin
  174. //      MsgBox(‘文件不存在’,mbConfirmation, MB_OK);
  175. //    end;
  176. // MsgBox(‘CurStepChanged:实际安装后调用’, mbConfirmation, MB_OKCANCEL);
  177. end;
  178. end;
  179. //下一步 按钮按钮 事件
  180. function NextButtonClick(CurPageID: Integer): Boolean;
  181. var ResultCode: Integer;
  182. var IsSetup : Boolean;
  183. begin
  184. IsSetup := true ;
  185. case CurPageID of
  186. wpSelectDir:
  187. MsgBox(‘NextButtonClick:’ #13#13 ‘You selected: ”’ + WizardDirValue + ”’.’, mbInformation, MB_OK);   //WizardDirValue 路径
  188. wpSelectProgramGroup:
  189. MsgBox(‘NextButtonClick:’ #13#13 ‘You selected: ”’ + WizardGroupValue + ”’.’, mbInformation, MB_OK); //开始菜单名
  190. wpReady:
  191. begin
  192. if not RegValueExists(HKEY_LOCAL_MACHINE, ‘SOFTWARE\Test’, ‘config’) then   begin
  193. if MsgBox(‘程序执行需要Test.ext,是否安装!’, mbConfirmation, MB_YESNO) = idYes then begin
  194. ExtractTemporaryFile(‘test.exe’);
  195. if not Exec(ExpandConstant(‘{tmp}\test.exe’), ”, ”, SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode) then
  196. MsgBox(‘Test.exe出错:’ #13#13 ‘ ‘ + SysErrorMessage(ResultCode) + ‘.’, mbError, MB_OK);
  197. end else begin
  198. IsSetup := false ;
  199. end ;
  200. BringToFrontAndRestore();
  201. end;
  202. end;
  203. end;
  204. Result := IsSetup;
  205. end;
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,036
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,522
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,370
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,151
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,784
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,866