DittoSetup_10.iss 15 KB

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