Compil32.dpr 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 'Src\SafeDLLPath.pas',
  11. Windows,
  12. SysUtils,
  13. Forms,
  14. PathFunc in '..\Components\PathFunc.pas',
  15. CompForm in 'Src\CompForm.pas' {CompileForm},
  16. CmnFunc in 'Src\CmnFunc.pas',
  17. CmnFunc2 in 'Src\CmnFunc2.pas',
  18. CompFunc in 'Src\CompFunc.pas',
  19. CompMsgs in 'Src\CompMsgs.pas',
  20. CompInt in 'Src\CompInt.pas',
  21. CompOptions in 'Src\CompOptions.pas' {OptionsForm},
  22. CompStartup in 'Src\CompStartup.pas' {StartupForm},
  23. CompWizard in 'Src\CompWizard.pas' {WizardForm},
  24. CompWizardFile in 'Src\CompWizardFile.pas' {WizardFileForm},
  25. CompFileAssoc in 'Src\CompFileAssoc.pas',
  26. TmSchema in '..\Components\TmSchema.pas',
  27. UxTheme in '..\Components\UxTheme.pas',
  28. DebugStruct in 'Src\DebugStruct.pas',
  29. BrowseFunc in 'Src\BrowseFunc.pas',
  30. CompSignTools in 'Src\CompSignTools.pas' {SignToolsForm},
  31. CompInputQueryCombo in 'Src\CompInputQueryCombo.pas',
  32. ScintInt in '..\Components\ScintInt.pas',
  33. ScintEdit in '..\Components\ScintEdit.pas',
  34. ScintStylerInnoSetup in '..\Components\ScintStylerInnoSetup.pas',
  35. ModernColors in '..\Components\ModernColors.pas',
  36. CompMsgBoxDesigner in 'Src\CompMsgBoxDesigner.pas' {MsgBoxDesignerForm},
  37. CompScintEdit in 'Src\CompScintEdit.pas',
  38. CompFilesDesigner in 'Src\CompFilesDesigner.pas' {FilesDesignerForm},
  39. CompWizardFilesHelper in 'Src\CompWizardFilesHelper.pas',
  40. NewTabSet in '..\Components\NewTabSet.pas',
  41. dwTaskbarList in '..\Components\dwTaskbarList.pas',
  42. NewStaticText in '..\Components\NewStaticText.pas',
  43. BidiUtils in '..\Components\BidiUtils.pas',
  44. DropListBox in '..\Components\DropListBox.pas',
  45. NewCheckListBox in '..\Components\NewCheckListBox.pas',
  46. NewNotebook in '..\Components\NewNotebook.pas',
  47. TaskbarProgressFunc in 'Src\TaskbarProgressFunc.pas',
  48. HtmlHelpFunc in 'Src\HtmlHelpFunc.pas',
  49. UIStateForm in 'Src\UIStateForm.pas',
  50. LangOptionsSectionDirectives in 'Src\LangOptionsSectionDirectives.pas',
  51. MsgIDs in 'Src\MsgIDs.pas',
  52. SetupSectionDirectives in 'Src\SetupSectionDirectives.pas',
  53. CompTypes in 'Src\CompTypes.pas',
  54. FileClass in 'Src\FileClass.pas',
  55. Int64Em in 'Src\Int64Em.pas',
  56. Compress in 'Src\Compress.pas',
  57. TaskDialog in 'Src\TaskDialog.pas';
  58. {$SetPEFlags IMAGE_FILE_RELOCS_STRIPPED}
  59. {$SETPEOSVERSION 6.1}
  60. {$SETPESUBSYSVERSION 6.1}
  61. {$WEAKLINKRTTI ON}
  62. {$R Res\Compil32.docicon.res}
  63. {$R Res\Compil32.manifest.res}
  64. {$R Res\Compil32.versionandicon.res}
  65. procedure SetAppUserModelID;
  66. var
  67. Func: function(AppID: PWideChar): HRESULT; stdcall;
  68. begin
  69. { For the IDE to be pinnable and show a Jump List, it is necessary to
  70. explicitly assign an AppUserModelID because by default the taskbar excludes
  71. applications that have "Setup" in their name. }
  72. Func := GetProcAddress(GetModuleHandle('shell32.dll'),
  73. 'SetCurrentProcessExplicitAppUserModelID');
  74. if Assigned(Func) then
  75. Func('JR.InnoSetup.IDE.6');
  76. end;
  77. procedure RegisterApplicationRestart;
  78. const
  79. RESTART_MAX_CMD_LINE = 1024;
  80. RESTART_NO_CRASH = $1;
  81. RESTART_NO_HANG = $2;
  82. RESTART_NO_PATCH = $4;
  83. RESTART_NO_REBOOT = $8;
  84. var
  85. Func: function(pwzCommandLine: PWideChar; dwFlags: DWORD): HRESULT; stdcall;
  86. CommandLine: WideString;
  87. begin
  88. { Allow Restart Manager to restart us after updates. }
  89. Func := GetProcAddress(GetModuleHandle('kernel32.dll'),
  90. 'RegisterApplicationRestart');
  91. if Assigned(Func) then begin
  92. { Rebuild the command line, can't just use an exact copy since it might contain
  93. relative path names but Restart Manager doesn't restore the working
  94. directory. }
  95. if CommandLineWizard then
  96. CommandLine := '/WIZARD'
  97. else begin
  98. CommandLine := CommandLineFilename;
  99. if CommandLine <> '' then
  100. CommandLine := '"' + CommandLine + '"';
  101. if CommandLineCompile then
  102. CommandLine := '/CC ' + CommandLine;
  103. end;
  104. if Length(CommandLine) > RESTART_MAX_CMD_LINE then
  105. CommandLine := '';
  106. Func(PWideChar(CommandLine), RESTART_NO_CRASH or RESTART_NO_HANG or RESTART_NO_REBOOT);
  107. end;
  108. end;
  109. procedure CreateMutexes;
  110. { Creates the two mutexes used by the Inno Setup's own installer/uninstaller to
  111. see if the compiler is still running.
  112. One of the mutexes is created in the global name space (which makes it
  113. possible to access the mutex across user sessions in Windows XP); the other
  114. is created in the session name space (because versions of Windows NT prior
  115. to 4.0 TSE don't have a global name space and don't support the 'Global\'
  116. prefix). }
  117. const
  118. MutexName = 'InnoSetupCompilerAppMutex';
  119. begin
  120. CreateMutex(MutexName);
  121. CreateMutex('Global\' + MutexName); { don't localize }
  122. end;
  123. var
  124. InitialCurDir: String;
  125. procedure CheckParams;
  126. procedure Error;
  127. begin
  128. MessageBox(0, SCompilerCommandLineHelp3, SCompilerFormCaption,
  129. MB_OK or MB_ICONEXCLAMATION);
  130. Halt(1);
  131. end;
  132. var
  133. P, I: Integer;
  134. S: String;
  135. Dummy: Boolean;
  136. begin
  137. P := NewParamCount;
  138. I := 1;
  139. while I <= P do begin
  140. S := NewParamStr(I);
  141. if CompareText(S, '/CC') = 0 then
  142. CommandLineCompile := True
  143. else if CompareText(S, '/WIZARD') = 0 then begin
  144. if I = P then
  145. Error;
  146. CommandLineWizard := True;
  147. CommandLineWizardName := NewParamStr(I+1);
  148. Inc(I);
  149. end
  150. else if CompareText(S, '/ASSOC') = 0 then begin
  151. try
  152. RegisterISSFileAssociation(False, Dummy);
  153. except
  154. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  155. Halt(2);
  156. end;
  157. Halt;
  158. end
  159. else if CompareText(S, '/UNASSOC') = 0 then begin
  160. try
  161. UnregisterISSFileAssociation;
  162. except
  163. MessageBox(0, PChar(GetExceptMessage), nil, MB_OK or MB_ICONSTOP);
  164. Halt(2);
  165. end;
  166. Halt;
  167. end
  168. else if (S = '') or (S[1] = '/') or (CommandLineFilename <> '') then
  169. Error
  170. else
  171. CommandLineFilename := PathExpand(PathCombine(InitialCurDir, S));
  172. Inc(I);
  173. end;
  174. if (CommandLineCompile or CommandLineWizard) and (CommandLineFilename = '') then
  175. Error;
  176. end;
  177. begin
  178. InitialCurDir := GetCurrentDir;
  179. if not SetCurrentDir(PathExtractDir(NewParamStr(0))) then
  180. SetCurrentDir(GetSystemDir);
  181. SetAppUserModelID;
  182. CreateMutexes;
  183. Application.Initialize;
  184. CheckParams;
  185. RegisterApplicationRestart;
  186. { The 'with' is so that the Delphi IDE doesn't mess with these }
  187. with Application do begin
  188. if CommandLineWizard then
  189. Title := CommandLineWizardName
  190. else
  191. Title := SCompilerFormCaption;
  192. end;
  193. Application.CreateForm(TCompileForm, CompileForm);
  194. Application.Run;
  195. end.