星火微课系统客户端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

星火微课-正式.iss 8.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. ; 脚本由 Inno Setup 脚本向导 生成!
  2. ; 有关创建 Inno Setup 脚本文件的详细资料请查阅帮助文档!
  3. #define MyAppName "星火微课"
  4. #define MyAppDir "xhwk"
  5. #define MyAppVersion "3.2.3"
  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: "\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. function CheckVC():boolean;
  52. var Path:string;
  53. ResultCode: Integer;
  54. begin
  55. if RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{01FAEC41-B3BC-44F4-B185-5E8475AEB855}', 'Version')
  56. or RegValueExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{77EB1EA9-8E1B-459D-8CDC-1984D0FF15B6}', 'Version')
  57. then
  58. begin
  59. Result := true;
  60. end
  61. else
  62. begin
  63. if MsgBox('系统检测到您没有安装VC++环境,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
  64. begin
  65. Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
  66. Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/vc_redist.x86.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  67. MsgBox('请安装好VC++环境后,再运行本安装包程序!',mbInformation,MB_OK);
  68. Result := false;
  69. end
  70. else
  71. begin
  72. MsgBox('取消后请手动安装VC2015-2019环境!',mbInformation,MB_OK);
  73. Result := true;
  74. end;
  75. end;
  76. end;
  77. function IsInstallDotNet(version: string; service: cardinal): boolean;
  78. var
  79. key, versionKey: string;
  80. install, release, serviceCount, versionRelease: cardinal;
  81. success: boolean;
  82. begin
  83. versionKey := version;
  84. versionRelease := 0;
  85. // .NET 1.1 and 2.0 embed release number in version key
  86. if version = 'v1.1' then begin
  87. versionKey := 'v1.1.4322';
  88. end
  89. else if version = 'v2.0' then begin
  90. versionKey := 'v2.0.50727';
  91. end
  92. // .NET 4.5 and newer install as update to .NET 4.0 Full
  93. else if Pos('v4.', version) = 1 then begin
  94. versionKey := 'v4\Full';
  95. case version of
  96. 'v4.5': versionRelease := 378389;
  97. 'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older
  98. 'v4.5.2': versionRelease := 379893;
  99. 'v4.6': versionRelease := 393295; // 393297 on Windows 8.1 and older
  100. 'v4.6.1': versionRelease := 394254; // 394271 on Windows 8.1 and older
  101. 'v4.6.2': versionRelease := 394802; // 394806 on Windows 8.1 and older
  102. 'v4.7': versionRelease := 460798; // Windows 10
  103. 'v4.7.1': versionRelease := 461308; // Windows 10
  104. 'v4.7.2': versionRelease := 461808; // Windows 10
  105. 'v4.8' : versionRelease := 528040; // Windows 10
  106. end;
  107. end;
  108. // installation key group for all .NET versions
  109. key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;
  110. // .NET 3.0 uses value InstallSuccess in subkey Setup
  111. if Pos('v3.0', version) = 1 then begin
  112. success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
  113. end else begin
  114. success := RegQueryDWordValue(HKLM, key, 'Install', install);
  115. end;
  116. // .NET 4.0 and newer use value Servicing instead of SP
  117. if Pos('v4', version) = 1 then begin
  118. success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
  119. end else begin
  120. success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
  121. end;
  122. // .NET 4.5 and newer use additional value Release
  123. if versionRelease > 0 then begin
  124. success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
  125. success := success and (release >= versionRelease);
  126. end;
  127. result := success and (install = 1) and (serviceCount >= service);
  128. end;
  129. // 检查.Net是否安装
  130. function CheckDotNet : Boolean;
  131. var Path:string;
  132. ResultCode: Integer;
  133. begin
  134. if IsInstallDotNet('v4.5.2', 0) then
  135. begin
  136. Result := true;
  137. end
  138. else
  139. begin
  140. if MsgBox('系统检测到您没有安装.Net Framework4.5.2,是否立刻下载并安装?', mbConfirmation, MB_YESNO) = idYes then
  141. begin
  142. Path := ExpandConstant('{pf}/Internet Explorer/iexplore.exe');
  143. Exec(Path, 'https://xhkjedu.oss-cn-huhehaote.aliyuncs.com/runtime/NDP452-KB2901907-x86-x64-AllOS-ENU.exe', '', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  144. MsgBox('请安装好.Net Framework环境后,再运行本安装包程序!',mbInformation,MB_OK);
  145. Result := false;
  146. end
  147. else
  148. begin
  149. MsgBox('没有安装.Net Framework环境,无法运行程序,本安装程序即将退出!',mbInformation,MB_OK);
  150. Result := false;
  151. end;
  152. end;
  153. end;
  154. function InitializeSetup: Boolean;
  155. begin
  156. Result := CheckDotNet();
  157. Result := CheckVC();
  158. end;
  159. // 自定义函数,判断软件是否运行,参数为需要判断的软件的exe名称
  160. function CheckSoftRun(strExeName: String): Boolean;
  161. // 变量定义
  162. var ErrorCode: Integer;
  163. var bRes: Boolean;
  164. var strFileContent: AnsiString;
  165. var strTmpPath: String; // 临时目录
  166. var strTmpFile: String; // 临时文件,保存查找软件数据结果
  167. var strCmdFind: String; // 查找软件命令
  168. var strCmdKill: String; // 终止软件命令
  169. begin
  170. strTmpPath := GetTempDir();
  171. strTmpFile := Format('%sfindSoftRes.txt', [strTmpPath]);
  172. strCmdFind := Format('/c tasklist /nh|find /c /i "%s" > "%s"', [strExeName, strTmpFile]);
  173. strCmdKill := Format('/c taskkill /f /t /im %s', [strExeName]);
  174. bRes := ShellExec('open', ExpandConstant('{cmd}'), strCmdFind, '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  175. if bRes then begin
  176. bRes := LoadStringFromFile(strTmpFile, strFileContent);
  177. strFileContent := Trim(strFileContent);
  178. if bRes then begin
  179. if StrToInt(strFileContent) > 0 then begin
  180. // 终止程序
  181. ShellExec('open', ExpandConstant('{cmd}'), strCmdKill, '', SW_HIDE, ewNoWait, ErrorCode);
  182. Result:= true;// 继续安装
  183. end else begin
  184. // 软件没在运行
  185. Result:= true;
  186. end;
  187. end;
  188. end;
  189. Result :=true;
  190. end;
  191. // 开始页下一步时判断软件是否运行
  192. function NextButtonClick(CurPageID: Integer): Boolean;
  193. begin
  194. if 1=CurPageID then begin
  195. Result := CheckSoftRun('{#MyAppExeName}');
  196. end
  197. else begin
  198. Result:= true;
  199. end;
  200. end;
  201. // 卸载时关闭软件
  202. function InitializeUninstall(): Boolean;
  203. begin
  204. Result := CheckSoftRun('{#MyAppExeName}');
  205. end;