DittoSetup_10.iss 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. #define MyAppName "Ditto"
  2. #define MyAppVersion GetFileVersion("..\Release\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 bit64
  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=DittoSetup_{#MyAppVersion}
  25. #ifdef bit64
  26. ArchitecturesInstallIn64BitMode=x64
  27. ArchitecturesAllowed=x64
  28. #endif
  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. #ifdef bit64
  90. Source: ..\Release64\Ditto.exe; DestDir: {app}; DestName: Ditto.exe; Flags: ignoreversion; AfterInstall: AddProgramToFirewall(ExpandConstant('{app}\Ditto.exe'), 'Ditto_FromInstaller_64');
  91. Source: ..\Release64\ICU_Loader.dll; DestDir: {app}; Flags: ignoreversion
  92. Source: ..\Release64\Addins\DittoUtil.dll; DestDir: {app}\Addins; Flags: ignoreversion
  93. ; "C:\Windows\sysnative" will be converted to "C:\Windows\System32"
  94. ; System32 stores a 64-bit DLL on x64 system
  95. Source: C:\Windows\sysnative\vcruntime140.dll; DestDir: {app}; Flags: ignoreversion
  96. Source: C:\Windows\sysnative\vcruntime140_1.dll; DestDir: {app}; Flags: ignoreversion
  97. Source: C:\Windows\sysnative\msvcp140.dll; DestDir: {app}; Flags: ignoreversion
  98. Source: C:\Windows\sysnative\mfc140u.dll; DestDir: {app}; Flags: ignoreversion
  99. #endif
  100. #ifndef bit64
  101. Source: ..\Release\Ditto.exe; DestDir: {app}; DestName: Ditto.exe; Flags: ignoreversion; AfterInstall: AddProgramToFirewall(ExpandConstant('{app}\Ditto.exe'), 'Ditto_FromInstaller_32');
  102. Source: ..\Release\ICU_Loader.dll; DestDir: {app}; Flags: ignoreversion
  103. Source: ..\Release\Addins\DittoUtil.dll; DestDir: {app}\Addins; Flags: ignoreversion
  104. Source: C:\Windows\SysWOW64\vcruntime140.dll; DestDir: {app}; Flags: ignoreversion
  105. Source: C:\Windows\SysWOW64\msvcp140.dll; DestDir: {app}; Flags: ignoreversion
  106. Source: C:\Windows\SysWOW64\mfc140u.dll; DestDir: {app}; Flags: ignoreversion
  107. #endif
  108. Source: ..\Debug\Language\*; DestDir: {app}\Language; BeforeInstall: BeforeLanguageInstall()
  109. Source: ..\Debug\Themes\*; DestDir: {app}\Themes
  110. [Icons]
  111. Name: {group}\Ditto; Filename: {app}\Ditto.exe
  112. Name: {group}\{cm:UninstallDitto}; Filename: {uninstallexe}
  113. [Run]
  114. Filename: {app}\Ditto.exe; Description: {cm:LaunchDitto}; Flags: nowait postinstall
  115. Filename: https://sourceforge.net/p/ditto-cp/wiki/Getting%20Started; Description: {cm:ViewHelp}; Flags: nowait postinstall skipifsilent shellexec unchecked
  116. Filename: https://ditto-cp.sourceforge.io/changeHistory.php; Description: {cm:ViewChangeHistory}; Flags: nowait postinstall skipifsilent shellexec unchecked
  117. [Registry]
  118. Root: HKCU; Subkey: Software\Ditto; Flags: uninsdeletekey
  119. Root: HKCU; Subkey: SOFTWARE\Microsoft\Windows\CurrentVersion\Run; ValueType: string; ValueName: Ditto; flags: uninsdeletevalue; ValueData: {app}\Ditto.exe; Tasks: RunAtStartup
  120. Root: HKCU; Subkey: Software\Ditto; ValueType: dword; ValueName: SetFocus_iexplore.exe; ValueData: 00000001
  121. Root: HKCU; Subkey: Software\Ditto; ValueType: string; ValueName: LanguageFile; ValueData: "{code:AdjustedLanguage|{language}}"
  122. Root: HKCU; Subkey: Software\Ditto\PasteStrings; ValueType: string; ValueName: gvim.exe; ValueData: """{{PLUS}gP"
  123. Root: HKCU; Subkey: Software\Ditto\CopyStrings; ValueType: string; ValueName: gvim.exe; ValueData: """{{PLUS}y"
  124. Root: HKCU; Subkey: Software\Ditto\CutStrings; ValueType: string; ValueName: gvim.exe; ValueData: """{{PLUS}x"
  125. Root: HKCU; Subkey: Software\Ditto\PasteStrings; ValueType: string; ValueName: cmd.exe; OnlyBelowVersion: 10; ValueData: % {{Delay100}ep
  126. Root: HKCU; Subkey: Software\Ditto\CopyStrings; ValueType: string; ValueName: cmd.exe; OnlyBelowVersion: 10; ValueData: % {{Delay100}ey
  127. Root: HKCU; Subkey: Software\Ditto\PasteStrings; ValueName: cmd.exe; MinVersion: 10; Flags: deletevalue
  128. Root: HKCU; Subkey: Software\Ditto\CopyStrings; ValueName: cmd.exe; MinVersion: 10; Flags: deletevalue
  129. ;associate .dto with Ditto
  130. Root: HKCR; Subkey: .dto; ValueType: string; ValueName: ; ValueData: Ditto; Flags: uninsdeletevalue
  131. Root: HKCR; Subkey: Ditto; ValueType: string; ValueName: ; ValueData: Ditto; Flags: uninsdeletekey
  132. Root: HKCR; Subkey: Ditto\DefaultIcon; ValueType: string; ValueName: ; ValueData: {app}\Ditto.exe,0
  133. Root: HKCR; Subkey: Ditto\shell\open\command; ValueType: string; ValueName: ; ValueData: """{app}\Ditto.exe"" ""%1"""
  134. [Code]
  135. procedure BeforeLanguageInstall();
  136. var
  137. sDir: String;
  138. begin
  139. end;
  140. function AdjustedLanguage(Param: String): String;
  141. begin
  142. Case Param of
  143. 'ChineseSimplified' : Result := 'Chinese Simplified';
  144. 'ChineseTraditional' : Result := 'Chinese Traditional';
  145. else
  146. Result := Param;
  147. end;
  148. end;
  149. procedure CleanupOldFiles();
  150. var
  151. sDir: String;
  152. begin
  153. sDir := ExpandConstant('{app}');
  154. DeleteFile(sDir+'\mfc100u.dll')
  155. DeleteFile(sDir+'\mfcm100u.dll')
  156. DeleteFile(sDir+'\msvcp100.dll')
  157. DeleteFile(sDir+'\msvcr100.dll')
  158. DeleteFile(sDir+'\iculx55.dll')
  159. DeleteFile(sDir+'\icule55.dll')
  160. DeleteFile(sDir+'\icuuc55.dll')
  161. DeleteFile(sDir+'\icutu55.dll')
  162. DeleteFile(sDir+'\icuio55.dll')
  163. DeleteFile(sDir+'\icuin55.dll')
  164. DeleteFile(sDir+'\icudt55.dll')
  165. //moved to use the windows included dll
  166. DeleteFile(sDir+'\icuuc58.dll')
  167. DeleteFile(sDir+'\icuin58.dll')
  168. DeleteFile(sDir+'\icutu58.dll')
  169. DeleteFile(sDir+'\icuio58.dll')
  170. DeleteFile(sDir+'\icudt58.dll')
  171. DelTree(sDir+'\Help', TRUE, TRUE, TRUE)
  172. end;
  173. procedure RegisterForCrashDump(theApp : String);
  174. var
  175. theExe : String;
  176. begin
  177. theExe := theApp + '.exe';
  178. if IsWin64() then
  179. begin
  180. if RegValueExists(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder') = false then
  181. RegWriteStringValue(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder', ExpandConstant('{userappdata}') + '\Ditto\Dumps');
  182. if RegValueExists(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType') = false then
  183. RegWriteDWordValue(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType', 2);
  184. if RegValueExists(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount') = false then
  185. RegWriteDWordValue(HKLM64, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount', 3);
  186. end
  187. else
  188. begin
  189. if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder') = false then
  190. RegWriteStringValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpFolder', ExpandConstant('{userappdata}') + '\Ditto\Dumps');
  191. if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType') = false then
  192. RegWriteDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpType', 2);
  193. if RegValueExists(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount') = false then
  194. RegWriteDWordValue(HKEY_LOCAL_MACHINE, 'Software\Microsoft\Windows\Windows Error Reporting\LocalDumps\' + theExe, 'DumpCount', 3);
  195. end;
  196. end;
  197. function IsVC2017CRuntimeInstalled(): Boolean;
  198. var
  199. Installed: Boolean;
  200. IsInstalled: Cardinal;
  201. begin
  202. Installed := false
  203. IsInstalled := 0;
  204. #ifdef bit64
  205. if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Installed', IsInstalled) then
  206. begin
  207. if (IsInstalled = 1) then
  208. begin
  209. Installed := true;
  210. end;
  211. end;
  212. //double check the HKLM64 key
  213. if (IsInstalled <> 1) and IsWin64() then
  214. begin
  215. if RegQueryDWordValue(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x64', 'Installed', IsInstalled) then
  216. begin
  217. if (IsInstalled = 1) then
  218. begin
  219. Installed := true;
  220. end;
  221. end;
  222. end;
  223. #endif
  224. #ifndef bit64
  225. if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Installed', IsInstalled) then
  226. begin
  227. if (IsInstalled = 1) then
  228. begin
  229. Installed := true;
  230. end;
  231. end;
  232. //double check the HKLM64 key
  233. if (IsInstalled <> 1) and IsWin64() then
  234. begin
  235. if RegQueryDWordValue(HKLM64, 'SOFTWARE\Microsoft\VisualStudio\14.0\VC\Runtimes\x86', 'Installed', IsInstalled) then
  236. begin
  237. if (IsInstalled = 1) then
  238. begin
  239. Installed := true;
  240. end;
  241. end;
  242. end;
  243. #endif
  244. Result := Installed;
  245. end;
  246. procedure CheckForPreReqs();
  247. var
  248. nReturnCode: Integer;
  249. begin
  250. end;
  251. procedure CurStepChanged(CurStep: TSetupStep);
  252. var
  253. ProgressPage: TOutputProgressWizardPage;
  254. ErrorCode : Integer;
  255. AbortNeeded: Boolean;
  256. begin
  257. AbortNeeded := false;
  258. case CurStep of
  259. ssInstall:
  260. begin
  261. CheckForPreReqs();
  262. end;
  263. ssPostInstall:
  264. begin
  265. end;
  266. ssDone:
  267. begin
  268. RegisterForCrashDump('Ditto')
  269. CleanupOldFiles()
  270. end;
  271. end;
  272. end;
  273. function RuleExistsInFirewall(RuleName : String) : Boolean;
  274. var
  275. ErrorCode : Integer;
  276. begin
  277. Exec('>', 'netsh advfirewall firewall show rule name="' + RuleName + '"', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  278. if ErrorCode = 0 then
  279. Result := True
  280. else
  281. Result := False;
  282. end;
  283. procedure AddProgramToFirewall(ProgramName : String; RuleName : String);
  284. var
  285. ErrorCode : Integer;
  286. Success : Boolean;
  287. WindowsVersion : TWindowsVersion;
  288. begin
  289. if IsTaskSelected('AddFireWallException') then
  290. begin
  291. GetWindowsVersionEx(WindowsVersion);
  292. if (WindowsVersion.Major < 6) then
  293. begin
  294. Success := Exec('>', 'netsh firewall add allowedprogram "' + ProgramName + '" "' + RuleName + '" ENABLE ALL', '', SW_HIDE, ewWaitUntilTerminated, ErrorCode);
  295. end
  296. else
  297. begin
  298. if (not RuleExistsInFirewall(RuleName)) then
  299. begin
  300. 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);
  301. 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);
  302. end
  303. end;
  304. if not Success then
  305. Log('Error - Unable to add ' + RuleName + ' to List of Windows firewall exceptions. ErrorCode: ' + IntToStr(ErrorCode))
  306. else
  307. Log(RuleName + ' successfully added to list of Windows firewall exceptions. ErrorCode: ' + IntToStr(ErrorCode))
  308. end
  309. end;