Compil32.dpr 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. program Compil32;
  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.LicenseKeyForm in 'Src\IDE.LicenseKeyForm.pas' {LicenseKeyForm},
  34. IDE.InputQueryComboForm in 'Src\IDE.InputQueryComboForm.pas',
  35. IDE.InputQueryMemoForm in 'Src\IDE.InputQueryMemoForm.pas',
  36. ScintInt in '..\Components\ScintInt.pas',
  37. ScintEdit in '..\Components\ScintEdit.pas',
  38. IDE.ScintStylerInnoSetup in 'Src\IDE.ScintStylerInnoSetup.pas',
  39. ModernColors in '..\Components\ModernColors.pas',
  40. IDE.MsgBoxDesignerForm in 'Src\IDE.MsgBoxDesignerForm.pas' {MsgBoxDesignerForm},
  41. IDE.IDEScintEdit in 'Src\IDE.IDEScintEdit.pas',
  42. IDE.FilesDesignerForm in 'Src\IDE.FilesDesignerForm.pas' {FilesDesignerForm},
  43. IDE.Wizard.WizardFormFilesHelper in 'Src\IDE.Wizard.WizardFormFilesHelper.pas',
  44. NewTabSet in '..\Components\NewTabSet.pas',
  45. NewStaticText in '..\Components\NewStaticText.pas',
  46. BidiUtils in '..\Components\BidiUtils.pas',
  47. DropListBox in '..\Components\DropListBox.pas',
  48. BitmapButton in '..\Components\BitmapButton.pas',
  49. BitmapImage in '..\Components\BitmapImage.pas',
  50. NewCheckListBox in '..\Components\NewCheckListBox.pas',
  51. NewNotebook in '..\Components\NewNotebook.pas',
  52. TaskbarProgressFunc in '..\Components\TaskbarProgressFunc.pas',
  53. IDE.HtmlHelpFunc in 'Src\IDE.HtmlHelpFunc.pas',
  54. UIStateForm in '..\Components\UIStateForm.pas',
  55. Shared.LangOptionsSectionDirectives in 'Src\Shared.LangOptionsSectionDirectives.pas',
  56. Shared.SetupMessageIDs in 'Src\Shared.SetupMessageIDs.pas',
  57. Shared.SetupSectionDirectives in 'Src\Shared.SetupSectionDirectives.pas',
  58. Shared.ConfigIniFile in 'Src\Shared.ConfigIniFile.pas',
  59. Shared.SignToolsFunc in 'Src\Shared.SignToolsFunc.pas',
  60. Shared.LicenseFunc in 'Src\Shared.LicenseFunc.pas',
  61. Shared.FileClass in 'Src\Shared.FileClass.pas',
  62. Shared.TaskDialogFunc in 'Src\Shared.TaskDialogFunc.pas',
  63. IDE.RegistryDesignerForm in 'Src\IDE.RegistryDesignerForm.pas' {RegistryDesignerForm},
  64. IDE.Wizard.WizardFormRegistryHelper in 'Src\IDE.Wizard.WizardFormRegistryHelper.pas',
  65. ScintInt.InnoSetup in '..\Components\ScintInt.InnoSetup.pas',
  66. Shared.ScriptFunc in 'Src\Shared.ScriptFunc.pas',
  67. Shared.SetupSteps in 'Src\Shared.SetupSteps.pas',
  68. Shared.Struct in 'Src\Shared.Struct.pas',
  69. SHA256 in '..\Components\SHA256.pas',
  70. Shared.DotNetVersion in 'Src\Shared.DotNetVersion.pas',
  71. isxclasses_wordlists_generated in '..\ISHelp\isxclasses_wordlists_generated.pas',
  72. IDE.ImagesModule in 'Src\IDE.ImagesModule.pas' {ImagesModule: TDataModule},
  73. ECDSA in '..\Components\ECDSA.pas',
  74. ISSigFunc in '..\Components\ISSigFunc.pas',
  75. StringScanner in '..\Components\StringScanner.pas',
  76. Resample in '..\Components\Resample.pas',
  77. VCL.Styles,
  78. VCL.Themes;
  79. {$SETPEOSVERSION 6.1}
  80. {$SETPESUBSYSVERSION 6.1}
  81. {$WEAKLINKRTTI ON}
  82. {$R Res\Compil32.docicon.res}
  83. {$R Res\Compil32.manifest.res}
  84. {$R Res\Compil32.versionandicon.res}
  85. {$R Res\Compil32.darkstyle.res}
  86. procedure SetAppUserModelID;
  87. var
  88. Func: function(AppID: PWideChar): HRESULT; stdcall;
  89. begin
  90. { For the IDE to be pinnable and show a Jump List, it is necessary to
  91. explicitly assign an AppUserModelID because by default the taskbar excludes
  92. applications that have "Setup" in their name. }
  93. Func := GetProcAddress(GetModuleHandle('shell32.dll'),
  94. 'SetCurrentProcessExplicitAppUserModelID');
  95. if Assigned(Func) then
  96. Func('JR.InnoSetup.IDE.6');
  97. end;
  98. procedure RegisterApplicationRestart;
  99. const
  100. RESTART_MAX_CMD_LINE = 1024;
  101. RESTART_NO_CRASH = $1;
  102. RESTART_NO_HANG = $2;
  103. RESTART_NO_PATCH = $4;
  104. RESTART_NO_REBOOT = $8;
  105. var
  106. Func: function(pwzCommandLine: PWideChar; dwFlags: DWORD): HRESULT; stdcall;
  107. CommandLine: WideString;
  108. begin
  109. { Allow Restart Manager to restart us after updates. }
  110. Func := GetProcAddress(GetModuleHandle('kernel32.dll'),
  111. 'RegisterApplicationRestart');
  112. if Assigned(Func) then begin
  113. { Rebuild the command line, can't just use an exact copy since it might contain
  114. relative path names but Restart Manager doesn't restore the working
  115. directory. }
  116. if CommandLineWizard then
  117. CommandLine := '/WIZARD'
  118. else begin
  119. CommandLine := CommandLineFilename;
  120. if CommandLine <> '' then
  121. CommandLine := '"' + CommandLine + '"';
  122. if CommandLineCompile then
  123. CommandLine := '/CC ' + CommandLine;
  124. end;
  125. if Length(CommandLine) > RESTART_MAX_CMD_LINE then
  126. CommandLine := '';
  127. Func(PWideChar(CommandLine), RESTART_NO_CRASH or RESTART_NO_HANG or RESTART_NO_REBOOT);
  128. end;
  129. end;
  130. procedure CreateMutexes;
  131. { Creates the two mutexes used by Inno Setup's own installer/uninstaller to
  132. see if the compiler is still running.
  133. One of the mutexes is created in the global name space (which makes it
  134. possible to access the mutex across user sessions in Windows XP); the other
  135. is created in the session name space (because versions of Windows NT prior
  136. to 4.0 TSE don't have a global name space and don't support the 'Global\'
  137. prefix). }
  138. const
  139. MutexName = 'InnoSetupCompilerAppMutex';
  140. begin
  141. CreateMutex(MutexName);
  142. CreateMutex('Global\' + MutexName); { don't localize }
  143. end;
  144. var
  145. InitialCurDir: String;
  146. procedure CheckParams;
  147. procedure Error;
  148. begin
  149. MessageBox(0, SCompilerCommandLineHelp3, SCompilerFormCaption,
  150. MB_OK or MB_ICONEXCLAMATION);
  151. Halt(1);
  152. end;
  153. var
  154. P, I: Integer;
  155. S: String;
  156. Dummy: Boolean;
  157. begin
  158. P := NewParamCount;
  159. I := 1;
  160. while I <= P do begin
  161. S := NewParamStr(I);
  162. if CompareText(S, '/CC') = 0 then
  163. CommandLineCompile := True
  164. else if CompareText(S, '/WIZARD') = 0 then begin
  165. if I = P then
  166. Error;
  167. CommandLineWizard := True;
  168. CommandLineWizardName := NewParamStr(I+1);
  169. Inc(I);
  170. end
  171. else if CompareText(S, '/ASSOC') = 0 then begin
  172. try
  173. RegisterISSFileAssociation(False, Dummy);
  174. except
  175. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  176. Halt(2);
  177. end;
  178. Halt;
  179. end
  180. else if CompareText(S, '/UNASSOC') = 0 then begin
  181. try
  182. UnregisterISSFileAssociation(True);
  183. except
  184. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  185. Halt(2);
  186. end;
  187. Halt;
  188. end
  189. else if (S = '') or (S[1] = '/') or (CommandLineFilename <> '') then
  190. Error
  191. else
  192. CommandLineFilename := PathExpand(PathCombine(InitialCurDir, S));
  193. Inc(I);
  194. end;
  195. if (CommandLineCompile or CommandLineWizard) and (CommandLineFilename = '') then
  196. Error;
  197. end;
  198. begin
  199. {$IFNDEF STATICCOMPILER}
  200. try
  201. InitISCmplrLibrary;
  202. except
  203. begin
  204. MessageBox(0, PChar(Format('Could not load %s: %s' {$IFDEF DEBUG} + #13#10#13#10'Did you build the ISCmplr project?' {$ENDIF},
  205. [ISCmplrDLL, GetExceptMessage])), nil, MB_OK or MB_ICONSTOP);
  206. Halt(3);
  207. end;
  208. end;
  209. {$ENDIF}
  210. try
  211. InitIsscintLibrary;
  212. except
  213. begin
  214. 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},
  215. [IsscintDLL, GetExceptMessage])), nil, MB_OK or MB_ICONSTOP);
  216. Halt(4);
  217. end;
  218. end;
  219. {$IFDEF DEBUG}
  220. ReportMemoryLeaksOnShutdown := True;
  221. {$ENDIF}
  222. InitialCurDir := GetCurrentDir;
  223. if not SetCurrentDir(PathExtractDir(NewParamStr(0))) then
  224. SetCurrentDir(GetSystemDir);
  225. SetAppUserModelID;
  226. CreateMutexes;
  227. Application.Initialize;
  228. CheckParams;
  229. RegisterApplicationRestart;
  230. if not CommandLineWizard then
  231. Application.MainFormOnTaskBar := True;
  232. { The 'with' is so that the Delphi IDE doesn't mess with these }
  233. with Application do begin
  234. if CommandLineWizard then
  235. Title := CommandLineWizardName
  236. else
  237. Title := SCompilerFormCaption;
  238. end;
  239. if Assigned(FlushMenuThemes) then begin
  240. { We don't need VCL Styles for dark menus. This keeps shDialogs and shTooltips. }
  241. TStyleManager.SystemHooks := TStyleManager.SystemHooks - [shMenus];
  242. end;
  243. Application.CreateForm(TImagesModule, ImagesModule);
  244. Application.CreateForm(TMainForm, MainForm);
  245. Application.Run;
  246. end.