星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

星火微课-测试.iss 9.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. ; 脚本由 Inno Setup 脚本向导 生成!
  2. ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
  3. #define MyAppName "星火微课"
  4. #define MyAppDir "xhwk"
  5. #define MyAppVersion "3.1.12"
  6. #define MyAppPublisher "河南星火燎原软件科技有限公司"
  7. #define MyAppURL "http://www.xhkjedu.com/"
  8. #define MySourcePath "D:\Project\CSharp\xhwkclient\XHWK.WKTool\bin\x86\Debug\"
  9. #define MyAppExeName "星火微课.exe"
  10. #define MyIcoName "256.ico"
  11. #define MyTargetPath "D:\程序打包\星火微课-测试\"
  12. [Setup]
  13. ; 注: AppId的值为单独标识该应用程序。
  14. ; 不要为其他安装程序使用相同的AppId值。
  15. ; (若要生成新的 GUID,可在菜单中点击 "工具|生成 GUID"。)
  16. AppId={{5869900A-3BE4-463E-B0A6-462AA7454AE2}
  17. AppName={#MyAppName}
  18. AppVersion={#MyAppVersion}
  19. ;AppVerName={#MyAppName} {#MyAppVersion}
  20. AppPublisher={#MyAppPublisher}
  21. AppPublisherURL={#MyAppURL}
  22. AppSupportURL={#MyAppURL}
  23. AppUpdatesURL={#MyAppURL}
  24. DefaultDirName={autopf}\{#MyAppDir}
  25. DisableProgramGroupPage=yes
  26. ; [Icons] 的“quicklaunchicon”条目使用 {userappdata},而其 [Tasks] 条目具有适合 IsAdminInstallMode 的检查。
  27. UsedUserAreasWarning=no
  28. ; 以下行取消注释,以在非管理安装模式下运行(仅为当前用户安装)。
  29. ;PrivilegesRequired=lowest
  30. OutputDir={#MyTargetPath}
  31. OutputBaseFilename="{#MyAppName} v{#MyAppVersion}"
  32. SetupIconFile="{#MySourcePath}{#MyIcoName}"
  33. Compression=lzma
  34. SolidCompression=yes
  35. WizardStyle=modern
  36. [Languages]
  37. Name: "chinesesimp"; MessagesFile: "compiler:Default.isl"
  38. [Tasks]
  39. Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone
  40. Name: "quicklaunchicon"; Description: "{cm:CreateQuickLaunchIcon}"; GroupDescription: "{cm:AdditionalIcons}"; Flags: checkablealone; OnlyBelowVersion: 6.1; Check: not IsAdminInstallMode
  41. [Files]
  42. Source: "{#MySourcePath}{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion
  43. Source: "{#MySourcePath}*"; Excludes: "ffmpeg.exe,\Log\*,\Temp,\Data";DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs
  44. [Icons]
  45. Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
  46. Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: desktopicon
  47. Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
  48. [Run]
  49. Filename: "{app}\{#MyAppExeName}"; Description: "{cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}"; Flags: nowait postinstall skipifsilent
  50. [Code]
  51. // 自定义函数,判断软件是否运行,参数为需要判断的软件的exe名称
  52. function KDetectSoft(strExeName: String): Boolean;
  53. // 变量定义
  54. var ErrorCode: Integer;
  55. var bRes: Boolean;
  56. var strFileContent: AnsiString;
  57. var strTmpPath: String; // 临时目录
  58. var strTmpFile: String; // 临时文件,保存查找软件数据结果
  59. var strCmdFind: String; // 查找软件命令
  60. var strCmdKill: String; // 终止软件命令
  61. begin
  62. strTmpPath := GetTempDir();
  63. strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
  64. strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
  65. strCmdKill := Format('/c taskkill /f /t /im %s', [strExeName]);
  66. bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  67. if bRes then begin
  68. bRes := LoadStringFromFile(strTmpFile, strFileContent);
  69. strFileContent := Trim(strFileContent);
  70. if bRes then begin
  71. if StrToInt(strFileContent) > 0 then begin
  72. if MsgBox(ExpandConstant('{cm:checkSoftTip}'), mbConfirmation, MB_OKCANCEL) = IDOK then begin
  73. // 终止程序
  74. ShellExec('open', ExpandConstant('{cmd}'), strCmdKill, '', SW_HIDE, ewNoWait, ErrorCode);
  75. Result:= true;// 继续安装
  76. end else begin
  77. Result:= false;// 安装程序退出
  78. Exit;
  79. end;
  80. end else begin
  81. // 软件没在运行
  82. Result:= true;
  83. Exit;
  84. end;
  85. end;
  86. end;
  87. Result :=true;
  88. end;
  89. // 开始页下一步时判断软件是否运行
  90. function NextButtonClick(CurPageID: Integer): Boolean;
  91. begin
  92. if 1=CurPageID then begin
  93. Result := KDetectSoft('{#MyAppExeName}');
  94. Exit;
  95. end;
  96. Result:= true;
  97. end;
  98. // 卸载时关闭软件
  99. function InitializeUninstall(): Boolean;
  100. begin
  101. Result := KDetectSoft('{#MyAppExeName}');
  102. end;
  103. // Indicates whether the specified version and service pack of the .NET Framework is installed.
  104. //
  105. // version -- Specify one of these strings for the required .NET Framework version:
  106. // 'v1.1' .NET Framework 1.1
  107. // 'v2.0' .NET Framework 2.0
  108. // 'v3.0' .NET Framework 3.0
  109. // 'v3.5' .NET Framework 3.5
  110. // 'v4\Client' .NET Framework 4.0 Client Profile
  111. // 'v4\Full' .NET Framework 4.0 Full Installation
  112. // 'v4.5' .NET Framework 4.5
  113. // 'v4.5.1' .NET Framework 4.5.1
  114. // 'v4.5.2' .NET Framework 4.5.2
  115. // 'v4.6' .NET Framework 4.6
  116. // 'v4.6.1' .NET Framework 4.6.1
  117. // 'v4.6.2' .NET Framework 4.6.2
  118. // 'v4.7' .NET Framework 4.7
  119. // 'v4.7.1' .NET Framework 4.7.1
  120. // 'v4.7.2' .NET Framework 4.7.2
  121. // 'v4.8' .NET Framework 4.8
  122. //
  123. // service -- Specify any non-negative integer for the required service pack level:
  124. // 0 No service packs required
  125. // 1, 2, etc. Service pack 1, 2, etc. required
  126. function IsDotNetDetected(version: string; service: cardinal): boolean;
  127. var
  128. key, versionKey: string;
  129. install, release, serviceCount, versionRelease: cardinal;
  130. success: boolean;
  131. begin
  132. versionKey := version;
  133. versionRelease := 0;
  134. // .NET 1.1 and 2.0 embed release number in version key
  135. if version = 'v1.1' then begin
  136. versionKey := 'v1.1.4322';
  137. end
  138. else if version = 'v2.0' then begin
  139. versionKey := 'v2.0.50727';
  140. end
  141. // .NET 4.5 and newer install as update to .NET 4.0 Full
  142. else if Pos('v4.', version) = 1 then begin
  143. versionKey := 'v4\Full';
  144. case version of
  145. 'v4.5': versionRelease := 378389;
  146. 'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older
  147. 'v4.5.2': versionRelease := 379893;
  148. 'v4.6': versionRelease := 393295; // 393297 on Windows 8.1 and older
  149. 'v4.6.1': versionRelease := 394254; // 394271 on Windows 8.1 and older
  150. 'v4.6.2': versionRelease := 394802; // 394806 on Windows 8.1 and older
  151. 'v4.7': versionRelease := 460798; // Windows 10
  152. 'v4.7.1': versionRelease := 461308; // Windows 10
  153. 'v4.7.2': versionRelease := 461808; // Windows 10
  154. 'v4.8' : versionRelease := 528040; // Windows 10
  155. end;
  156. end;
  157. // installation key group for all .NET versions
  158. key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;
  159. // .NET 3.0 uses value InstallSuccess in subkey Setup
  160. if Pos('v3.0', version) = 1 then begin
  161. success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
  162. end else begin
  163. success := RegQueryDWordValue(HKLM, key, 'Install', install);
  164. end;
  165. // .NET 4.0 and newer use value Servicing instead of SP
  166. if Pos('v4', version) = 1 then begin
  167. success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
  168. end else begin
  169. success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
  170. end;
  171. // .NET 4.5 and newer use additional value Release
  172. if versionRelease > 0 then begin
  173. success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
  174. success := success and (release >= versionRelease);
  175. end;
  176. result := success and (install = 1) and (serviceCount >= service);
  177. end;
  178. function InitializeSetup: Boolean;
  179. var Path:string;
  180. ResultCode: Integer;
  181. begin
  182. if IsDotNetDetected('v4.5.2', 0) then
  183. begin
  184. if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version') then
  185. begin
  186. Result := true;
  187. end
  188. else
  189. begin
  190. if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
  191. begin
  192. Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
  193. Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/VC_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  194. MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);
  195. Result := false;
  196. end
  197. else
  198. begin
  199. MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);
  200. Result := true;
  201. end;
  202. end;
  203. end
  204. else
  205. begin
  206. if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
  207. begin
  208. Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
  209. Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  210. MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);
  211. Result := false;
  212. end
  213. else
  214. begin
  215. MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);
  216. Result := false;
  217. end;
  218. end;
  219. end;
  220. [CustomMessages]
  221. chinesesimp.checkSoftTip=安装程序检测到将安装的软件正在运行!%n%n点击"确定"终止软件后继续操作,否则点击"取消"。