Compil32.dpr 9.3 KB

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