DittoSetup_10.iss 13 KB

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