Compil32.dpr 8.9 KB

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