DittoSetup_10.iss 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. #define MyAppName "Ditto"
  2. #define MyAppVersion GetFileVersion("..\Release64\Ditto.exe")
  3. #define MyAppVerName MyAppName + " " + MyAppVersion
  4. #define MyAppPublisher "Scott Brogden"
  5. #define MyAppSupportURL "ditto-cp.sourceforge.net"
  6. #define MyAppCopyrighEndYear GetDateTimeString('yyyy','','')
  7. #define MyOutputBaseFilename "DittoSetup_" + GetEnv('VERSION_FILENAME')
  8. [Setup]
  9. AppName={#MyAppName}
  10. AppVersion={#MyAppVersion}
  11. AppVerName={#MyAppVerName}
  12. AppPublisher={# MyAppPublisher}
  13. AppPublisherURL={#MyAppSupportURL}
  14. AppSupportURL={#MyAppSupportURL}
  15. AppUpdatesURL={#MyAppSupportURL}
  16. WizardStyle=modern
  17. UninstallDisplayIcon={app}\Ditto.exe
  18. UninstallDisplayName={#MyAppName}
  19. VersionInfoDescription={#MyAppName} installer
  20. VersionInfoVersion={#MyAppVersion}
  21. VersionInfoProductName={#MyAppName}
  22. VersionInfoProductVersion={#MyAppVersion}
  23. AppCopyright={#MyAppPublisher} {#MyAppCopyrighEndYear}
  24. OutputBaseFilename={#MyOutputBaseFilename}
  25. ArchitecturesInstallIn64BitMode=x64compatible
  26. ArchitecturesAllowed=x64compatible
  27. DefaultDirName={pf}\{#MyAppName}
  28. DefaultGroupName={#MyAppName}
  29. ;UsePreviousTasks=no
  30. ;DisableDirPage=yes
  31. DisableProgramGroupPage=yes
  32. DisableReadyPage=yes
  33. DirExistsWarning=no
  34. UninstallLogMode=overwrite
  35. ChangesAssociations=yes
  36. CloseApplications=yes
  37. MinVersion=6.1
  38. SetupLogging=yes
  39. [Languages]
  40. Name: English; MessagesFile: compiler:Default.isl
  41. ;Inno Setup Official translations
  42. Name: Czech; MessagesFile: compiler:Languages\Czech.isl
  43. Name: Danish; MessagesFile: compiler:Languages\Danish.isl
  44. Name: Dutch; MessagesFile: compiler:Languages\Dutch.isl
  45. Name: Finnish; MessagesFile: compiler:Languages\Finnish.isl
  46. Name: French; MessagesFile: compiler:Languages\French.isl
  47. Name: Deutsch; MessagesFile: compiler:Languages\German.isl
  48. Name: Hebrew; MessagesFile: compiler:Languages\Hebrew.isl
  49. Name: Italiano; MessagesFile: compiler:Languages\Italian.isl
  50. Name: Japanese; MessagesFile: compiler:Languages\Japanese.isl
  51. Name: Polski; MessagesFile: compiler:Languages\Polish.isl
  52. Name: Portuguese; MessagesFile: compiler:Languages\Portuguese.isl
  53. Name: Russian; MessagesFile: compiler:Languages\Russian.isl
  54. Name: Slovak; MessagesFile: compiler:Languages\Slovak.isl
  55. Name: Slovenian; MessagesFile: compiler:Languages\Slovenian.isl
  56. Name: Spanish; MessagesFile: compiler:Languages\Spanish.isl
  57. Name: Turkish; MessagesFile: compiler:Languages\Turkish.isl
  58. Name: Ukrainian; MessagesFile: compiler:Languages\Ukrainian.isl
  59. ;Inno Setup Unofficial translations
  60. Name: ChineseSimplified; MessagesFile: ChineseSimplified.isl
  61. Name: ChineseTraditional; MessagesFile: ChineseTraditional.isl
  62. Name: Croatian; MessagesFile: Croatian.isl
  63. Name: Greek; MessagesFile: Greek.isl
  64. Name: Hungarian; MessagesFile: Hungarian.isl
  65. Name: Korean; MessagesFile: Korean.isl
  66. Name: Romanian; MessagesFile: Romanian.isl
  67. Name: Swedish; MessagesFile: Swedish.isl
  68. [CustomMessages]
  69. English.RunDittoOnStartup=Run Ditto on Windows startup
  70. English.AddFirewallException=Add Windows Firewall exception for Ditto on port 23443
  71. English.LaunchDitto=Launch Ditto
  72. English.ViewHelp=View Help
  73. English.ViewChangeHistory=View Change History
  74. English.UninstallDitto=Uninstall Ditto
  75. English.VCRuntimeInstallFailed=VCRuntime prerequisite install failed.
  76. Italiano.RunDittoOnStartup=Esegui Ditto all'avvio di Windows
  77. Italiano.AddFirewallException=Aggiungi eccezione a Windows Firewall per Ditto e la porta 23443
  78. Italiano.LaunchDitto=Esegui Ditto
  79. Italiano.ViewHelp=Visualizza guida in linea
  80. Italiano.ViewChangeHistory=Visualizza cronologia versioni programma
  81. Italiano.UninstallDitto=Disinstalla Ditto
  82. Italiano.VCRuntimeInstallFailed=Installazione prerequisito VCRuntime non riuscita.
  83. [Tasks]
  84. Name: RunAtStartup; Description: {cm:RunDittoOnStartup}
  85. Name: AddFireWallException; Description: {cm:AddFirewallException}; Flags: unchecked
  86. [Files]
  87. Source: ..\Release64\Ditto.exe; DestDir: {app}; DestName: Ditto.exe; Flags: ignoreversion; AfterInstall: AddProgramToFirewall(ExpandConstant('{app}\Ditto.exe'), 'Ditto_FromInstaller_64');
  88. Source: ..\Release64\ICU_Loader.dll; DestDir: {app}; Flags: ignoreversion
  89. Source: ..\Release64\Addins\DittoUtil.dll; DestDir: {app}\Addins; Flags: ignoreversion
  90. ; "C:\Windows\sysnative" will be converted to "C:\Windows\System32"
  91. ; System32 stores a 64-bit DLL on x64 system
  92. Source: C:\Windows\sysnative\vcruntime140.dll; DestDir: {app}; Flags: ignoreversion
  93. Source: C:\Windows\sysnative\vcruntime140_1.dll; DestDir: {app}; Flags: ignoreversion
  94. Source: C:\Windows\sysnative\msvcp140.dll; DestDir: {app}; Flags: ignoreversion
  95. Source: C:\Windows\sysnative\mfc140u.dll; DestDir: {app}; Flags: ignoreversion
  96. Source: ..\Debug\Language\*; DestDir: {app}\Language; BeforeInstall: BeforeLanguageInstall()
  97. Source: ..\Debug\Themes\*; DestDir: {app}\Themes
  98. [Icons]
  99. Name: {group}\Ditto; Filename: {app}\Ditto.exe
  100. Name: {group}\{cm:UninstallDitto}; Filename: {uninstallexe}
  101. [Run]
  102. Filename: {app}\Ditto.exe; Description: {cm:LaunchDitto}; Flags: nowait postinstall
  103. Filename: https://sourceforge.net/p/ditto-cp/wiki/Getting%20Started; Description: {cm:ViewHelp}; Flags: nowait postinstall skipifsilent shellexec unchecked
  104. Filename: https://ditto-cp.sourceforge.io/changeHistory.php; Description: {cm:ViewChangeHistory}; Flags: nowait postinstall skipifsilent shellexec unchecked
  105. [Registry]
  106. Root: HKCU; Subkey: Software\Ditto; Flags: uninsdeletekey
  107. Root: HKCU; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Run; ValueType: string; ValueName: Ditto; flags: uninsdeletevalue; ValueData: {app}\Ditto.exe; Tasks: RunAtStartup
  108. Root: HKCU; Subkey: Software\Ditto; ValueType: dword; ValueName: SetFocus_iexplore.exe; ValueData: 00000001
  109. Root: HKCU; Subkey: Software\Ditto; ValueType: string; ValueName: LanguageFile; ValueData: "{code:AdjustedLanguage|{language}}"
  110. Root: HKCU; Subkey: Software\Ditto\PasteStrings; ValueType: string; ValueName: gvim.exe; ValueData: """{{PLUS}gP"
  111. Root: HKCU; Subkey: Software\Ditto\CopyStrings; ValueType: string; ValueName: gvim.exe; ValueData: """{{PLUS}y"
  112. Root: HKCU; Subkey: Software\Ditto\CutStrings; ValueType: string; ValueName: gvim.exe; ValueData: """{{PLUS}x"
  113. Root: HKCU; Subkey: Software\Ditto\PasteStrings; ValueType: string; ValueName: cmd.exe; OnlyBelowVersion: 10; ValueData: % {{Delay100}ep
  114. Root: HKCU; Subkey: Software\Ditto\CopyStrings; ValueType: string; ValueName: cmd.exe; OnlyBelowVersion: 10; ValueData: % {{Delay100}ey
  115. Root: HKCU; Subkey: Software\Ditto\PasteStrings; ValueName: cmd.exe; MinVersion: 10; Flags: deletevalue
  116. Root: HKCU; Subkey: Software\Ditto\CopyStrings; ValueName: cmd.exe; MinVersion: 10; Flags: deletevalue
  117. ;associate .dto with Ditto
  118. Root: HKCR; Subkey: .dto; ValueType: string; ValueName: ; ValueData: Ditto; Flags: uninsdeletevalue
  119. Root: HKCR; Subkey: Ditto; ValueType: string; ValueName: ; ValueData: Ditto; Flags: uninsdeletekey
  120. Root: HKCR; Subkey: Ditto\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Ditto.exe,0
  121. Root: HKCR; Subkey: Ditto\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\Ditto.exe"" ""%1"""
  122. [Code]
  123. procedure BeforeLanguageInstall();
  124. var
  125. sDir: String;
  126. begin
  127. end;
  128. function AdjustedLanguage(Param: String): String;
  129. begin
  130. Case Param of
  131. 'ChineseSimplified' : Result := 'Chinese Simplified';
  132. 'ChineseTraditional' : Result := 'Chinese Traditional';
  133. else
  134. Result := Param;
  135. end;
  136. end;
  137. procedure CleanupOldFiles();
  138. var
  139. sDir: String;
  140. begin
  141. sDir := ExpandConstant('{app}');
  142. DeleteFile(sDir+'\mfc100u.dll')
  143. DeleteFile(sDir+'\mfcm100u.dll')
  144. DeleteFile(sDir+'\msvcp100.dll')
  145. DeleteFile(sDir+'\msvcr100.dll')
  146. DeleteFile(sDir+'\iculx55.dll')
  147. DeleteFile(sDir+'\icule55.dll')
  148. DeleteFile(sDir+'\icuuc55.dll')
  149. DeleteFile(sDir+'\icutu55.dll')
  150. DeleteFile(sDir+'\icuio55.dll')
  151. DeleteFile(sDir+'\icuin55.dll')
  152. DeleteFile(sDir+'\icudt55.dll')
  153. //moved to use the windows included dll
  154. DeleteFile(sDir+'\icuuc58.dll')
  155. DeleteFile(sDir+'\icuin58.dll')
  156. DeleteFile(sDir+'\icutu58.dll')
  157. DeleteFile(sDir+'\icuio58.dll')
  158. DeleteFile(sDir+'\icudt58.dll')
  159. DelTree(sDir+'\Help', TRUE, TRUE, TRUE)
  160. end;
  161. procedure RegisterForCrashDump(theApp : String);
  162. var
  163. theExe : String;
  164. begin
  165. theExe := theApp + '.exe';
  166. if IsWin64() then
  167. begin
  168. if RegValueExists(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder') = false then
  169. RegWriteStringValue(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder', ExpandConstant('{userappdata}') + '\Ditto\Dumps');
  170. if RegValueExists(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType') = false then
  171. RegWriteDWordValue(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType', 2);
  172. if RegValueExists(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount') = false then
  173. RegWriteDWordValue(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount', 3);
  174. end
  175. else
  176. begin
  177. if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder') = false then
  178. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder', ExpandConstant('{userappdata}') + '\Ditto\Dumps');
  179. if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType') = false then
  180. RegWriteDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType', 2);
  181. if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount') = false then
  182. RegWriteDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount', 3);
  183. end;
  184. end;
  185. function IsVC2017CRuntimeInstalled(): Boolean;
  186. var
  187. Installed: Boolean;
  188. IsInstalled: Cardinal;
  189. begin
  190. Installed := false
  191. IsInstalled := 0;
  192. if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Installed', IsInstalled) then
  193. begin
  194. if (IsInstalled = 1) then
  195. begin
  196. Installed := true;
  197. end;
  198. end;
  199. //double check the HKLM64 key
  200. if (IsInstalled <> 1) and IsWin64() then
  201. begin
  202. if RegQueryDWordValue(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Installed', IsInstalled) then
  203. begin
  204. if (IsInstalled = 1) then
  205. begin
  206. Installed := true;
  207. end;
  208. end;
  209. end;
  210. Result := Installed;
  211. end;
  212. procedure CheckForPreReqs();
  213. var
  214. nReturnCode: Integer;
  215. begin
  216. end;
  217. procedure CurStepChanged(CurStep: TSetupStep);
  218. var
  219. ProgressPage: TOutputProgressWizardPage;
  220. ErrorCode : Integer;
  221. AbortNeeded: Boolean;
  222. begin
  223. AbortNeeded := false;
  224. case CurStep of
  225. ssInstall:
  226. begin
  227. CheckForPreReqs();
  228. end;
  229. ssPostInstall:
  230. begin
  231. end;
  232. ssDone:
  233. begin
  234. RegisterForCrashDump('Ditto')
  235. CleanupOldFiles()
  236. end;
  237. end;
  238. end;
  239. function RuleExistsInFirewall(RuleName : String) : Boolean;
  240. var
  241. ErrorCode : Integer;
  242. begin
  243. Exec('>', 'netsh advfirewall firewall show rule name="' + RuleName + '"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  244. if ErrorCode = 0 then
  245. Result := True
  246. else
  247. Result := False;
  248. end;
  249. procedure AddProgramToFirewall(ProgramName : String; RuleName : String);
  250. var
  251. ErrorCode : Integer;
  252. Success : Boolean;
  253. WindowsVersion : TWindowsVersion;
  254. begin
  255. if IsTaskSelected('AddFireWallException') then
  256. begin
  257. GetWindowsVersionEx(WindowsVersion);
  258. if (WindowsVersion.Major < 6) then
  259. begin
  260. Success := Exec('>', 'netsh firewall add allowedprogram "' + ProgramName + '" "' + RuleName + '" ENABLE ALL', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  261. end
  262. else
  263. begin
  264. if (not RuleExistsInFirewall(RuleName)) then
  265. begin
  266. Success := Exec('>', 'netsh advfirewall firewall add rule name="' + RuleName + '" dir=in action=allow protocol=TCP localport=23443 program="' + ProgramName + '" enable=yes', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  267. Success := Exec('>', 'netsh advfirewall firewall add rule name="' + RuleName + '" dir=out action=allow protocol=TCP localport=23443 program="' + ProgramName + '" enable=yes', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  268. end
  269. end;
  270. if not Success then
  271. Log('Error - Unable to add ' + RuleName + ' to List of Windows firewall exceptions. ErrorCode: ' + IntToStr(ErrorCode))
  272. else
  273. Log(RuleName + ' successfully added to list of Windows firewall exceptions. ErrorCode: ' + IntToStr(ErrorCode))
  274. end
  275. end;