ISIDE.dpr 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. program ISIDE;
  2. {
  3. Inno Setup
  4. Copyright (C) 1997-2025 Jordan Russell
  5. Portions by Martijn Laan
  6. For conditions of distribution and use, see LICENSE.TXT.
  7. Compiler
  8. }
  9. uses
  10. SafeDLLPath in '..\Components\SafeDLLPath.pas',
  11. Windows,
  12. SysUtils,
  13. Forms,
  14. PathFunc in '..\Components\PathFunc.pas',
  15. TrustFunc in '..\Components\TrustFunc.pas',
  16. IDE.MainForm in 'Src\IDE.MainForm.pas' {MainForm},
  17. Shared.CommonFunc.Vcl in 'Src\Shared.CommonFunc.Vcl.pas',
  18. Shared.CommonFunc in 'Src\Shared.CommonFunc.pas',
  19. IDE.HelperFunc in 'Src\IDE.HelperFunc.pas',
  20. IDE.Messages in 'Src\IDE.Messages.pas',
  21. Shared.CompilerInt in 'Src\Shared.CompilerInt.pas',
  22. Shared.CompilerInt.Struct in 'Src\Shared.CompilerInt.Struct.pas',
  23. IDE.OptionsForm in 'Src\IDE.OptionsForm.pas' {OptionsForm},
  24. IDE.StartupForm in 'Src\IDE.StartupForm.pas' {StartupForm},
  25. IDE.Wizard.WizardForm in 'Src\IDE.Wizard.WizardForm.pas' {WizardForm},
  26. IDE.Wizard.WizardFileForm in 'Src\IDE.Wizard.WizardFileForm.pas' {WizardFileForm},
  27. IDE.FileAssocFunc in 'Src\IDE.FileAssocFunc.pas',
  28. NewUxTheme.TmSchema in '..\Components\NewUxTheme.TmSchema.pas',
  29. NewUxTheme in '..\Components\NewUxTheme.pas',
  30. Shared.DebugStruct in 'Src\Shared.DebugStruct.pas',
  31. BrowseFunc in '..\Components\BrowseFunc.pas',
  32. IDE.SignToolsForm in 'Src\IDE.SignToolsForm.pas' {SignToolsForm},
  33. IDE.GotoFileForm in 'Src\IDE.GotoFileForm.pas' {GotoFileForm},
  34. IDE.LicenseKeyForm in 'Src\IDE.LicenseKeyForm.pas' {LicenseKeyForm},
  35. IDE.InputQueryComboForm in 'Src\IDE.InputQueryComboForm.pas' {InputQueryComboForm},
  36. IDE.InputQueryMemoForm in 'Src\IDE.InputQueryMemoForm.pas' {InputQueryMemoForm},
  37. ScintInt in '..\Components\ScintInt.pas',
  38. ScintEdit in '..\Components\ScintEdit.pas',
  39. IDE.ScintStylerInnoSetup in 'Src\IDE.ScintStylerInnoSetup.pas',
  40. ModernColors in '..\Components\ModernColors.pas',
  41. IDE.MsgBoxDesignerForm in 'Src\IDE.MsgBoxDesignerForm.pas' {MsgBoxDesignerForm},
  42. IDE.IDEScintEdit in 'Src\IDE.IDEScintEdit.pas',
  43. IDE.FilesDesignerForm in 'Src\IDE.FilesDesignerForm.pas' {FilesDesignerForm},
  44. IDE.Wizard.WizardFormFilesHelper in 'Src\IDE.Wizard.WizardFormFilesHelper.pas',
  45. NewTabSet in '..\Components\NewTabSet.pas',
  46. NewStaticText in '..\Components\NewStaticText.pas',
  47. BidiUtils in '..\Components\BidiUtils.pas',
  48. DropListBox in '..\Components\DropListBox.pas',
  49. BitmapButton in '..\Components\BitmapButton.pas',
  50. BitmapImage in '..\Components\BitmapImage.pas',
  51. NewCheckListBox in '..\Components\NewCheckListBox.pas',
  52. NewNotebook in '..\Components\NewNotebook.pas',
  53. TaskbarProgressFunc in '..\Components\TaskbarProgressFunc.pas',
  54. IDE.HtmlHelpFunc in 'Src\IDE.HtmlHelpFunc.pas',
  55. UIStateForm in '..\Components\UIStateForm.pas',
  56. Shared.LangOptionsSectionDirectives in 'Src\Shared.LangOptionsSectionDirectives.pas',
  57. Shared.SetupMessageIDs in 'Src\Shared.SetupMessageIDs.pas',
  58. Shared.SetupSectionDirectives in 'Src\Shared.SetupSectionDirectives.pas',
  59. Shared.ConfigIniFile in 'Src\Shared.ConfigIniFile.pas',
  60. Shared.SignToolsFunc in 'Src\Shared.SignToolsFunc.pas',
  61. Shared.LicenseFunc in 'Src\Shared.LicenseFunc.pas',
  62. Shared.FileClass in 'Src\Shared.FileClass.pas',
  63. Shared.TaskDialogFunc in 'Src\Shared.TaskDialogFunc.pas',
  64. IDE.RegistryDesignerForm in 'Src\IDE.RegistryDesignerForm.pas' {RegistryDesignerForm},
  65. IDE.Wizard.WizardFormRegistryHelper in 'Src\IDE.Wizard.WizardFormRegistryHelper.pas',
  66. ScintInt.InnoSetup in '..\Components\ScintInt.InnoSetup.pas',
  67. Shared.ScriptFunc in 'Src\Shared.ScriptFunc.pas',
  68. Shared.SetupSteps in 'Src\Shared.SetupSteps.pas',
  69. Shared.Struct in 'Src\Shared.Struct.pas',
  70. SHA256 in '..\Components\SHA256.pas',
  71. Shared.DotNetVersion in 'Src\Shared.DotNetVersion.pas',
  72. isxclasses_wordlists_generated in '..\ISHelp\isxclasses_wordlists_generated.pas',
  73. IDE.ImagesModule in 'Src\IDE.ImagesModule.pas' {ImagesModule: TDataModule},
  74. ECDSA in '..\Components\ECDSA.pas',
  75. ISSigFunc in '..\Components\ISSigFunc.pas',
  76. StringScanner in '..\Components\StringScanner.pas',
  77. Resample in '..\Components\Resample.pas',
  78. UnsignedFunc in '..\Components\UnsignedFunc.pas',
  79. VCL.Styles,
  80. VCL.Themes,
  81. IDE.MainForm.MRUHelper in 'Src\IDE.MainForm.MRUHelper.pas',
  82. IDE.MainForm.UAHHelper in 'Src\IDE.MainForm.UAHHelper.pas',
  83. IDE.MainForm.NavigationHelper in 'Src\IDE.MainForm.NavigationHelper.pas',
  84. IDE.MainForm.FindReplaceHelper in 'Src\IDE.MainForm.FindReplaceHelper.pas',
  85. IDE.MainForm.UpdateMenuHelper in 'Src\IDE.MainForm.UpdateMenuHelper.pas',
  86. IDE.MainForm.ToolsHelper in 'Src\IDE.MainForm.ToolsHelper.pas',
  87. IDE.MainForm.AutoCompleteAndCallTipsHelper in 'Src\IDE.MainForm.AutoCompleteAndCallTipsHelper.pas',
  88. IDE.MainForm.ScintHelper in 'Src\IDE.MainForm.ScintHelper.pas',
  89. IDE.MainForm.FinalHelper in 'Src\IDE.MainForm.FinalHelper.pas';
  90. {$SETPEOSVERSION 6.1}
  91. {$SETPESUBSYSVERSION 6.1}
  92. {$WEAKLINKRTTI ON}
  93. {$R *.res}
  94. {$R Res\ISIDE.docicon.res}
  95. {$IFNDEF WIN64}
  96. {$R Res\ISIDE-x86.manifest.res}
  97. {$ELSE}
  98. {$R Res\ISIDE-x64.manifest.res}
  99. {$ENDIF}
  100. {$R Res\ISIDE.versionandicon.res}
  101. procedure SetAppUserModelID;
  102. var
  103. Func: function(AppID: PWideChar): HRESULT; stdcall;
  104. begin
  105. { For the IDE to be pinnable and show a Jump List, it is necessary to
  106. explicitly assign an AppUserModelID because by default the taskbar excludes
  107. applications that have "Setup" in their name. }
  108. Func := GetProcAddress(GetModuleHandle('shell32.dll'),
  109. 'SetCurrentProcessExplicitAppUserModelID');
  110. if Assigned(Func) then
  111. Func('JR.InnoSetup.IDE.7' {$IFDEF WIN64} + '-x64' {$ENDIF});
  112. end;
  113. procedure RegisterApplicationRestart;
  114. const
  115. RESTART_MAX_CMD_LINE = 1024;
  116. RESTART_NO_CRASH = $1;
  117. RESTART_NO_HANG = $2;
  118. RESTART_NO_PATCH = $4;
  119. RESTART_NO_REBOOT = $8;
  120. var
  121. Func: function(pwzCommandLine: PWideChar; dwFlags: DWORD): HRESULT; stdcall;
  122. CommandLine: WideString;
  123. begin
  124. { Allow Restart Manager to restart us after updates. }
  125. Func := GetProcAddress(GetModuleHandle('kernel32.dll'),
  126. 'RegisterApplicationRestart');
  127. if Assigned(Func) then begin
  128. { Rebuild the command line, can't just use an exact copy since it might contain
  129. relative path names but Restart Manager doesn't restore the working
  130. directory. }
  131. if CommandLineWizard then
  132. CommandLine := '/WIZARD'
  133. else begin
  134. CommandLine := CommandLineFilename;
  135. if CommandLine <> '' then
  136. CommandLine := '"' + CommandLine + '"';
  137. if CommandLineCompile then
  138. CommandLine := '/CC ' + CommandLine;
  139. end;
  140. if Length(CommandLine) > RESTART_MAX_CMD_LINE then
  141. CommandLine := '';
  142. Func(PWideChar(CommandLine), RESTART_NO_CRASH or RESTART_NO_HANG or RESTART_NO_REBOOT);
  143. end;
  144. end;
  145. procedure CreateMutexes;
  146. { Creates the two mutexes used by Inno Setup's own installer/uninstaller to
  147. see if the compiler is still running.
  148. One of the mutexes is created in the global name space (which makes it
  149. possible to access the mutex across user sessions in Windows XP); the other
  150. is created in the session name space (because versions of Windows NT prior
  151. to 4.0 TSE don't have a global name space and don't support the 'Global\'
  152. prefix). }
  153. const
  154. MutexName = 'InnoSetupCompilerAppMutex7' {$IFDEF WIN64} + '-x64' {$ENDIF};
  155. begin
  156. CreateMutex(MutexName);
  157. CreateMutex('Global\' + MutexName); { don't localize }
  158. end;
  159. var
  160. InitialCurDir: String;
  161. procedure CheckParams;
  162. procedure Error;
  163. begin
  164. MessageBox(0, SCompilerCommandLineHelp3, SCompilerFormCaption,
  165. MB_OK or MB_ICONEXCLAMATION);
  166. Halt(1);
  167. end;
  168. var
  169. P, I: Integer;
  170. S: String;
  171. Dummy: Boolean;
  172. begin
  173. P := NewParamCount;
  174. I := 1;
  175. while I <= P do begin
  176. S := NewParamStr(I);
  177. if CompareText(S, '/CC') = 0 then
  178. CommandLineCompile := True
  179. else if CompareText(S, '/WIZARD') = 0 then begin
  180. if I = P then
  181. Error;
  182. CommandLineWizard := True;
  183. CommandLineWizardName := NewParamStr(I+1);
  184. Inc(I);
  185. end
  186. else if CompareText(S, '/ASSOC') = 0 then begin
  187. try
  188. RegisterISSFileAssociation(False, Dummy);
  189. except
  190. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  191. Halt(2);
  192. end;
  193. Halt;
  194. end
  195. else if CompareText(S, '/UNASSOC') = 0 then begin
  196. try
  197. UnregisterISSFileAssociation(True);
  198. except
  199. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  200. Halt(2);
  201. end;
  202. Halt;
  203. end
  204. else if (S = '') or (S[1] = '/') or (CommandLineFilename <> '') then
  205. Error
  206. else
  207. CommandLineFilename := PathExpand(PathCombine(InitialCurDir, S));
  208. Inc(I);
  209. end;
  210. if (CommandLineCompile or CommandLineWizard) and (CommandLineFilename = '') then
  211. Error;
  212. end;
  213. begin
  214. {$IFNDEF STATICCOMPILER}
  215. try
  216. InitISCmplrLibrary;
  217. except
  218. begin
  219. MessageBox(0, PChar(Format('Could not load %s: %s' {$IFDEF DEBUG} + #13#10#13#10'Did you build the ISCmplr project?' {$ENDIF},
  220. [ISCmplrDLL, GetExceptMessage])), nil, MB_OK or MB_ICONSTOP);
  221. Halt(3);
  222. end;
  223. end;
  224. {$ENDIF}
  225. try
  226. InitIsscintLibrary;
  227. except
  228. begin
  229. MessageBox(0, PChar(Format('Could not load %s: %s' {$IFDEF DEBUG} + #13#10#13#10'Did you run Projects\Bin\synch-isfiles.bat as instructed in README.md?' {$ENDIF},
  230. [IsscintDLL, GetExceptMessage])), nil, MB_OK or MB_ICONSTOP);
  231. Halt(4);
  232. end;
  233. end;
  234. {$IFDEF DEBUG}
  235. ReportMemoryLeaksOnShutdown := True;
  236. {$ENDIF}
  237. InitialCurDir := GetCurrentDir;
  238. if not SetCurrentDir(PathExtractDir(NewParamStr(0))) then
  239. SetCurrentDir(GetSystemDir);
  240. SetAppUserModelID;
  241. CreateMutexes;
  242. Application.Initialize;
  243. CheckParams;
  244. RegisterApplicationRestart;
  245. if not CommandLineWizard then
  246. Application.MainFormOnTaskBar := True;
  247. { The 'with' is so that the Delphi IDE doesn't mess with these }
  248. with Application do begin
  249. if CommandLineWizard then
  250. Title := CommandLineWizardName
  251. else
  252. Title := SCompilerFormCaption;
  253. end;
  254. { Don't allow VCL Styles to style menus using owner drawing. Instead we get native dark menus
  255. using SetPreferredAppMode and FlushMenuThemes in IDE.MainForm. If you get light menus anyway on
  256. modern Windows then you should update the version check at the bottom of NewUxTheme. Using
  257. VCL Styles anyway, for example on older versions of Windows, is not the correct approach:
  258. TSysPopupStyleHook does not support our use of bitmaps set using MIIM_BITMAP on a TMenuItem, nor
  259. does it support our fake shortcuts set with SetFakeShortCut. }
  260. TStyleManager.SystemHooks := TStyleManager.SystemHooks - [shMenus]; { This keeps shDialogs and shTooltips }
  261. Application.CreateForm(TImagesModule, ImagesModule);
  262. Application.CreateForm(TMainForm, MainForm);
  263. Application.Run;
  264. end.