星火微课系统客户端
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 8.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. ; 脚本由 Inno Setup 脚本向导 生成!
  2. ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
  3. #define MyAppName "星火微课"
  4. #define MyAppDir "xhwk"
  5. #define MyAppVersion "3.2.0"
  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 CheckSoftRun(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 := CheckSoftRun('{#MyAppExeName}');
  94. Exit;
  95. end;
  96. Result:= true;
  97. end;
  98. // 卸载时关闭软件
  99. function InitializeUninstall(): Boolean;
  100. begin
  101. Result := CheckSoftRun('{#MyAppExeName}');
  102. end;
  103. function CheckVC():boolean;
  104. var Path:string;
  105. ResultCode: Integer;
  106. begin
  107. if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version')
  108. or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{77EB1EA9-8E1B-459D-8CDC-1984D0FF15B6}', 'Version')
  109. then
  110. begin
  111. Result := true;
  112. end
  113. else
  114. begin
  115. if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
  116. begin
  117. Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
  118. Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/vc_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  119. MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);
  120. Result := false;
  121. end
  122. else
  123. begin
  124. MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);
  125. Result := true;
  126. end;
  127. end;
  128. end;
  129. function IsInstallDotNet(version: string; service: cardinal): boolean;
  130. var
  131. key, versionKey: string;
  132. install, release, serviceCount, versionRelease: cardinal;
  133. success: boolean;
  134. begin
  135. versionKey := version;
  136. versionRelease := 0;
  137. // .NET 1.1 and 2.0 embed release number in version key
  138. if version = 'v1.1' then begin
  139. versionKey := 'v1.1.4322';
  140. end
  141. else if version = 'v2.0' then begin
  142. versionKey := 'v2.0.50727';
  143. end
  144. // .NET 4.5 and newer install as update to .NET 4.0 Full
  145. else if Pos('v4.', version) = 1 then begin
  146. versionKey := 'v4\Full';
  147. case version of
  148. 'v4.5': versionRelease := 378389;
  149. 'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older
  150. 'v4.5.2': versionRelease := 379893;
  151. 'v4.6': versionRelease := 393295; // 393297 on Windows 8.1 and older
  152. 'v4.6.1': versionRelease := 394254; // 394271 on Windows 8.1 and older
  153. 'v4.6.2': versionRelease := 394802; // 394806 on Windows 8.1 and older
  154. 'v4.7': versionRelease := 460798; // Windows 10
  155. 'v4.7.1': versionRelease := 461308; // Windows 10
  156. 'v4.7.2': versionRelease := 461808; // Windows 10
  157. 'v4.8' : versionRelease := 528040; // Windows 10
  158. end;
  159. end;
  160. // installation key group for all .NET versions
  161. key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;
  162. // .NET 3.0 uses value InstallSuccess in subkey Setup
  163. if Pos('v3.0', version) = 1 then begin
  164. success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
  165. end else begin
  166. success := RegQueryDWordValue(HKLM, key, 'Install', install);
  167. end;
  168. // .NET 4.0 and newer use value Servicing instead of SP
  169. if Pos('v4', version) = 1 then begin
  170. success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
  171. end else begin
  172. success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
  173. end;
  174. // .NET 4.5 and newer use additional value Release
  175. if versionRelease > 0 then begin
  176. success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
  177. success := success and (release >= versionRelease);
  178. end;
  179. result := success and (install = 1) and (serviceCount >= service);
  180. end;
  181. // 检查.Net是否安装
  182. function CheckDotNet : Boolean;
  183. var Path:string;
  184. ResultCode: Integer;
  185. begin
  186. if IsInstallDotNet('v4.5.2', 0) then
  187. begin
  188. Result := true;
  189. end
  190. else
  191. begin
  192. if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
  193. begin
  194. Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
  195. Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  196. MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);
  197. Result := false;
  198. end
  199. else
  200. begin
  201. MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);
  202. Result := false;
  203. end;
  204. end;
  205. end;
  206. function InitializeSetup: Boolean;
  207. begin
  208. Result := CheckDotNet();
  209. Result := CheckVC();
  210. end;
  211. [CustomMessages]
  212. chinesesimp.checkSoftTip=安装程序检测到将安装的软件正在运行!%n%n点击"确定"终止软件后继续操作,否则点击"取消"。