Compil32.dpr 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  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. UnsignedFunc in '..\Components\UnsignedFunc.pas',
  78. VCL.Styles,
  79. VCL.Themes,
  80. IDE.MainForm.MRUHelper in 'Src\IDE.MainForm.MRUHelper.pas',
  81. IDE.MainForm.UAHHelper in 'Src\IDE.MainForm.UAHHelper.pas',
  82. IDE.MainForm.NavigationHelper in 'Src\IDE.MainForm.NavigationHelper.pas',
  83. IDE.MainForm.FindReplaceHelper in 'Src\IDE.MainForm.FindReplaceHelper.pas',
  84. IDE.MainForm.UpdateMenuHelper in 'Src\IDE.MainForm.UpdateMenuHelper.pas',
  85. IDE.MainForm.ToolsHelper in 'Src\IDE.MainForm.ToolsHelper.pas',
  86. IDE.MainForm.AutoCompleteAndCallTipsHelper in 'Src\IDE.MainForm.AutoCompleteAndCallTipsHelper.pas',
  87. IDE.MainForm.ScintHelper in 'Src\IDE.MainForm.ScintHelper.pas',
  88. IDE.MainForm.FinalHelper in 'Src\IDE.MainForm.FinalHelper.pas';
  89. {$SETPEOSVERSION 6.1}
  90. {$SETPESUBSYSVERSION 6.1}
  91. {$WEAKLINKRTTI ON}
  92. {$R Res\Compil32.docicon.res}
  93. {$R Res\Compil32.manifest.res}
  94. {$R Res\Compil32.versionandicon.res}
  95. {$R Res\Compil32.darkstyle.res}
  96. procedure SetAppUserModelID;
  97. var
  98. Func: function(AppID: PWideChar): HRESULT; stdcall;
  99. begin
  100. { For the IDE to be pinnable and show a Jump List, it is necessary to
  101. explicitly assign an AppUserModelID because by default the taskbar excludes
  102. applications that have "Setup" in their name. }
  103. Func := GetProcAddress(GetModuleHandle('shell32.dll'),
  104. 'SetCurrentProcessExplicitAppUserModelID');
  105. if Assigned(Func) then
  106. Func('JR.InnoSetup.IDE.6');
  107. end;
  108. procedure RegisterApplicationRestart;
  109. const
  110. RESTART_MAX_CMD_LINE = 1024;
  111. RESTART_NO_CRASH = $1;
  112. RESTART_NO_HANG = $2;
  113. RESTART_NO_PATCH = $4;
  114. RESTART_NO_REBOOT = $8;
  115. var
  116. Func: function(pwzCommandLine: PWideChar; dwFlags: DWORD): HRESULT; stdcall;
  117. CommandLine: WideString;
  118. begin
  119. { Allow Restart Manager to restart us after updates. }
  120. Func := GetProcAddress(GetModuleHandle('kernel32.dll'),
  121. 'RegisterApplicationRestart');
  122. if Assigned(Func) then begin
  123. { Rebuild the command line, can't just use an exact copy since it might contain
  124. relative path names but Restart Manager doesn't restore the working
  125. directory. }
  126. if CommandLineWizard then
  127. CommandLine := '/WIZARD'
  128. else begin
  129. CommandLine := CommandLineFilename;
  130. if CommandLine <> '' then
  131. CommandLine := '"' + CommandLine + '"';
  132. if CommandLineCompile then
  133. CommandLine := '/CC ' + CommandLine;
  134. end;
  135. if Length(CommandLine) > RESTART_MAX_CMD_LINE then
  136. CommandLine := '';
  137. Func(PWideChar(CommandLine), RESTART_NO_CRASH or RESTART_NO_HANG or RESTART_NO_REBOOT);
  138. end;
  139. end;
  140. procedure CreateMutexes;
  141. { Creates the two mutexes used by Inno Setup's own installer/uninstaller to
  142. see if the compiler is still running.
  143. One of the mutexes is created in the global name space (which makes it
  144. possible to access the mutex across user sessions in Windows XP); the other
  145. is created in the session name space (because versions of Windows NT prior
  146. to 4.0 TSE don't have a global name space and don't support the 'Global\'
  147. prefix). }
  148. const
  149. MutexName = 'InnoSetupCompilerAppMutex';
  150. begin
  151. CreateMutex(MutexName);
  152. CreateMutex('Global\' + MutexName); { don't localize }
  153. end;
  154. var
  155. InitialCurDir: String;
  156. procedure CheckParams;
  157. procedure Error;
  158. begin
  159. MessageBox(0, SCompilerCommandLineHelp3, SCompilerFormCaption,
  160. MB_OK or MB_ICONEXCLAMATION);
  161. Halt(1);
  162. end;
  163. var
  164. P, I: Integer;
  165. S: String;
  166. Dummy: Boolean;
  167. begin
  168. P := NewParamCount;
  169. I := 1;
  170. while I <= P do begin
  171. S := NewParamStr(I);
  172. if CompareText(S, '/CC') = 0 then
  173. CommandLineCompile := True
  174. else if CompareText(S, '/WIZARD') = 0 then begin
  175. if I = P then
  176. Error;
  177. CommandLineWizard := True;
  178. CommandLineWizardName := NewParamStr(I+1);
  179. Inc(I);
  180. end
  181. else if CompareText(S, '/ASSOC') = 0 then begin
  182. try
  183. RegisterISSFileAssociation(False, Dummy);
  184. except
  185. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  186. Halt(2);
  187. end;
  188. Halt;
  189. end
  190. else if CompareText(S, '/UNASSOC') = 0 then begin
  191. try
  192. UnregisterISSFileAssociation(True);
  193. except
  194. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  195. Halt(2);
  196. end;
  197. Halt;
  198. end
  199. else if (S = '') or (S[1] = '/') or (CommandLineFilename <> '') then
  200. Error
  201. else
  202. CommandLineFilename := PathExpand(PathCombine(InitialCurDir, S));
  203. Inc(I);
  204. end;
  205. if (CommandLineCompile or CommandLineWizard) and (CommandLineFilename = '') then
  206. Error;
  207. end;
  208. begin
  209. {$IFNDEF STATICCOMPILER}
  210. try
  211. InitISCmplrLibrary;
  212. except
  213. begin
  214. MessageBox(0, PChar(Format('Could not load %s: %s' {$IFDEF DEBUG} + #13#10#13#10'Did you build the ISCmplr project?' {$ENDIF},
  215. [ISCmplrDLL, GetExceptMessage])), nil, MB_OK or MB_ICONSTOP);
  216. Halt(3);
  217. end;
  218. end;
  219. {$ENDIF}
  220. try
  221. InitIsscintLibrary;
  222. except
  223. begin
  224. 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},
  225. [IsscintDLL, GetExceptMessage])), nil, MB_OK or MB_ICONSTOP);
  226. Halt(4);
  227. end;
  228. end;
  229. {$IFDEF DEBUG}
  230. ReportMemoryLeaksOnShutdown := True;
  231. {$ENDIF}
  232. InitialCurDir := GetCurrentDir;
  233. if not SetCurrentDir(PathExtractDir(NewParamStr(0))) then
  234. SetCurrentDir(GetSystemDir);
  235. SetAppUserModelID;
  236. CreateMutexes;
  237. Application.Initialize;
  238. CheckParams;
  239. RegisterApplicationRestart;
  240. if not CommandLineWizard then
  241. Application.MainFormOnTaskBar := True;
  242. { The 'with' is so that the Delphi IDE doesn't mess with these }
  243. with Application do begin
  244. if CommandLineWizard then
  245. Title := CommandLineWizardName
  246. else
  247. Title := SCompilerFormCaption;
  248. end;
  249. { Don't allow VCL Styles to style menus using owner drawing. Instead we get native dark menus
  250. using SetPreferredAppMode and FlushMenuThemes in IDE.MainForm. If you get light menus anyway on
  251. modern Windows then you should update the version check at the bottom of NewUxTheme. Using
  252. VCL Styles anyway, for example on older versions of Windows, is not the correct approach:
  253. TSysPopupStyleHook does not support our use of bitmaps set using MIIM_BITMAP on a TMenuItem, nor
  254. does it support our fake shortcuts set with SetFakeShortCut. }
  255. TStyleManager.SystemHooks := TStyleManager.SystemHooks - [shMenus]; { This keeps shDialogs and shTooltips }
  256. Application.CreateForm(TImagesModule, ImagesModule);
  257. Application.CreateForm(TMainForm, MainForm);
  258. Application.Run;
  259. end.