DittoSetup_10.iss 12 KB

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