2011-10-06 20:53:09 +02:00
program Compil32;
{
Inno Setup
2024-03-27 13:20:38 +01:00
Copyright ( C) 1 9 9 7 - 2 0 2 4 Jordan Russell
2011-10-06 20:53:09 +02:00
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE. TXT.
Compiler
}
uses
2024-08-05 20:52:57 +02:00
SafeDLLPath in '..\Components\SafeDLLPath.pas' ,
2011-10-06 20:53:09 +02:00
Windows,
SysUtils,
Forms,
2024-03-31 17:05:20 +02:00
PathFunc in '..\Components\PathFunc.pas' ,
2025-03-12 22:35:37 +01:00
TrustFunc in '..\Components\TrustFunc.pas' ,
2024-08-06 18:36:53 +02:00
IDE. MainForm in 'Src\IDE.MainForm.pas' {MainForm} ,
2024-08-04 19:59:25 +02:00
Shared. CommonFunc. Vcl in 'Src\Shared.CommonFunc.Vcl.pas' ,
Shared. CommonFunc in 'Src\Shared.CommonFunc.pas' ,
2024-08-05 16:55:47 +02:00
IDE. HelperFunc in 'Src\IDE.HelperFunc.pas' ,
IDE. Messages in 'Src\IDE.Messages.pas' ,
2024-08-04 19:59:25 +02:00
Shared. CompilerInt in 'Src\Shared.CompilerInt.pas' ,
2025-03-12 22:35:37 +01:00
Shared. CompilerInt. Struct in 'Src\Shared.CompilerInt.Struct.pas' ,
2024-08-05 16:55:47 +02:00
IDE. OptionsForm in 'Src\IDE.OptionsForm.pas' {OptionsForm} ,
IDE. StartupForm in 'Src\IDE.StartupForm.pas' {StartupForm} ,
IDE. Wizard. WizardForm in 'Src\IDE.Wizard.WizardForm.pas' {WizardForm} ,
IDE. Wizard. WizardFileForm in 'Src\IDE.Wizard.WizardFileForm.pas' {WizardFileForm} ,
IDE. FileAssocFunc in 'Src\IDE.FileAssocFunc.pas' ,
2024-08-04 21:40:15 +02:00
NewUxTheme. TmSchema in '..\Components\NewUxTheme.TmSchema.pas' ,
2024-04-16 19:58:07 +02:00
NewUxTheme in '..\Components\NewUxTheme.pas' ,
2024-08-03 21:19:08 +02:00
Shared. DebugStruct in 'Src\Shared.DebugStruct.pas' ,
2024-08-05 20:52:57 +02:00
BrowseFunc in '..\Components\BrowseFunc.pas' ,
2024-08-05 16:55:47 +02:00
IDE. SignToolsForm in 'Src\IDE.SignToolsForm.pas' {SignToolsForm} ,
IDE. InputQueryComboForm in 'Src\IDE.InputQueryComboForm.pas' ,
2024-08-09 14:45:28 +02:00
IDE. InputQueryMemoForm in 'Src\IDE.InputQueryMemoForm.pas' ,
2011-10-06 20:53:09 +02:00
ScintInt in '..\Components\ScintInt.pas' ,
ScintEdit in '..\Components\ScintEdit.pas' ,
2024-08-05 16:55:47 +02:00
IDE. ScintStylerInnoSetup in 'Src\IDE.ScintStylerInnoSetup.pas' ,
2020-07-02 11:50:43 +02:00
ModernColors in '..\Components\ModernColors.pas' ,
2024-08-05 16:55:47 +02:00
IDE. MsgBoxDesignerForm in 'Src\IDE.MsgBoxDesignerForm.pas' {MsgBoxDesignerForm} ,
2024-08-06 18:28:41 +02:00
IDE. IDEScintEdit in 'Src\IDE.IDEScintEdit.pas' ,
2024-08-05 16:55:47 +02:00
IDE. FilesDesignerForm in 'Src\IDE.FilesDesignerForm.pas' {FilesDesignerForm} ,
IDE. Wizard. WizardFormFilesHelper in 'Src\IDE.Wizard.WizardFormFilesHelper.pas' ,
2024-03-31 17:05:20 +02:00
NewTabSet in '..\Components\NewTabSet.pas' ,
NewStaticText in '..\Components\NewStaticText.pas' ,
BidiUtils in '..\Components\BidiUtils.pas' ,
DropListBox in '..\Components\DropListBox.pas' ,
NewCheckListBox in '..\Components\NewCheckListBox.pas' ,
2024-03-31 21:10:44 +02:00
NewNotebook in '..\Components\NewNotebook.pas' ,
2024-08-05 20:52:57 +02:00
TaskbarProgressFunc in '..\Components\TaskbarProgressFunc.pas' ,
2024-08-05 16:55:47 +02:00
IDE. HtmlHelpFunc in 'Src\IDE.HtmlHelpFunc.pas' ,
2024-08-05 20:52:57 +02:00
UIStateForm in '..\Components\UIStateForm.pas' ,
2024-08-03 21:19:08 +02:00
Shared. LangOptionsSectionDirectives in 'Src\Shared.LangOptionsSectionDirectives.pas' ,
2024-08-04 19:59:25 +02:00
Shared. SetupMessageIDs in 'Src\Shared.SetupMessageIDs.pas' ,
2024-08-03 21:19:08 +02:00
Shared. SetupSectionDirectives in 'Src\Shared.SetupSectionDirectives.pas' ,
2024-08-04 21:32:25 +02:00
Shared. ConfigIniFile in 'Src\Shared.ConfigIniFile.pas' ,
Shared. SignToolsFunc in 'Src\Shared.SignToolsFunc.pas' ,
2024-08-03 21:19:08 +02:00
Shared. FileClass in 'Src\Shared.FileClass.pas' ,
Shared. Int64Em in 'Src\Shared.Int64Em.pas' ,
2024-08-04 19:59:25 +02:00
Shared. TaskDialogFunc in 'Src\Shared.TaskDialogFunc.pas' ,
2024-08-05 16:55:47 +02:00
IDE. RegistryDesignerForm in 'Src\IDE.RegistryDesignerForm.pas' {RegistryDesignerForm} ,
IDE. Wizard. WizardFormRegistryHelper in 'Src\IDE.Wizard.WizardFormRegistryHelper.pas' ,
2024-08-04 21:40:15 +02:00
ScintInt. InnoSetup in '..\Components\ScintInt.InnoSetup.pas' ,
2024-08-03 21:19:08 +02:00
Shared. ScriptFunc in 'Src\Shared.ScriptFunc.pas' ,
2024-09-27 16:07:30 +02:00
Shared. SetupSteps in 'Src\Shared.SetupSteps.pas' ,
2024-08-03 21:19:08 +02:00
Shared. Struct in 'Src\Shared.Struct.pas' ,
2024-09-01 19:44:15 +02:00
SHA256 in '..\Components\SHA256.pas' ,
2024-08-03 21:19:08 +02:00
Shared. DotNetVersion in 'Src\Shared.DotNetVersion.pas' ,
2024-08-09 08:43:14 +02:00
isxclasses_wordlists_generated in '..\ISHelp\isxclasses_wordlists_generated.pas' ,
2025-04-16 21:13:14 +02:00
IDE. ImagesModule in 'Src\IDE.ImagesModule.pas' {ImagesModule: TDataModule} ,
ECDSA in '..\Components\ECDSA.pas' ,
ISSigFunc in '..\Components\ISSigFunc.pas' ,
StringScanner in '..\Components\StringScanner.pas' ;
2011-10-06 20:53:09 +02:00
2024-03-27 13:20:38 +01:00
{$SETPEOSVERSION 6.1}
{$SETPESUBSYSVERSION 6.1}
2024-03-13 00:32:59 +01:00
{$WEAKLINKRTTI ON}
2024-04-03 10:09:12 +02:00
{$R Res\Compil32.docicon.res}
{$R Res\Compil32.manifest.res}
{$R Res\Compil32.versionandicon.res}
2011-10-06 20:53:09 +02:00
procedure SetAppUserModelID;
var
Func: function( AppID: PWideChar ) : HRESULT; stdcall ;
begin
2024-03-28 16:52:26 +01:00
{ For the IDE to be pinnable and show a Jump List, it is necessary to
explicitly assign an AppUserModelID because by default the taskbar excludes
applications that have "Setup" in their name . }
2011-10-06 20:53:09 +02:00
Func : = GetProcAddress( GetModuleHandle( 'shell32.dll' ) ,
'SetCurrentProcessExplicitAppUserModelID' ) ;
if Assigned( Func) then
2018-07-16 19:09:55 +02:00
Func( 'JR.InnoSetup.IDE.6' ) ;
2011-10-06 20:53:09 +02:00
end ;
2012-01-05 17:14:12 +01:00
procedure RegisterApplicationRestart;
const
2012-01-06 16:46:31 +01:00
RESTART_MAX_CMD_LINE = 1 0 2 4 ;
2012-01-05 17:14:12 +01:00
RESTART_NO_CRASH = $1 ;
RESTART_NO_HANG = $2 ;
RESTART_NO_PATCH = $4 ;
RESTART_NO_REBOOT = $8 ;
var
Func: function( pwzCommandLine: PWideChar ; dwFlags: DWORD) : HRESULT; stdcall ;
2012-01-11 10:55:23 +01:00
CommandLine: WideString ;
2012-01-05 17:14:12 +01:00
begin
2012-01-06 14:53:24 +01:00
{ Allow Restart Manager to restart us after updates. }
2012-01-06 16:46:31 +01:00
2012-01-05 17:14:12 +01:00
Func : = GetProcAddress( GetModuleHandle( 'kernel32.dll' ) ,
'RegisterApplicationRestart' ) ;
2012-01-06 16:46:31 +01:00
if Assigned( Func) then begin
{ Rebuild the command line, can' t just use an exact copy since it might contain
relative path names but Restart Manager doesn' t restore the working
directory. }
if CommandLineWizard then
CommandLine : = '/WIZARD'
else begin
CommandLine : = CommandLineFilename;
if CommandLine < > '' then
CommandLine : = '"' + CommandLine + '"' ;
if CommandLineCompile then
CommandLine : = '/CC ' + CommandLine;
end ;
2023-06-08 11:34:15 +08:00
2012-01-11 10:55:23 +01:00
if Length( CommandLine) > RESTART_MAX_CMD_LINE then
CommandLine : = '' ;
2012-01-06 16:46:31 +01:00
2012-01-11 10:55:23 +01:00
Func( PWideChar( CommandLine) , RESTART_NO_CRASH or RESTART_NO_HANG or RESTART_NO_REBOOT) ;
2012-01-06 16:46:31 +01:00
end ;
2012-01-05 17:14:12 +01:00
end ;
2011-10-06 20:53:09 +02:00
procedure CreateMutexes;
2024-07-10 20:20:04 +02:00
{ Creates the two mutexes used by Inno Setup' s own installer/ uninstaller to
2011-10-06 20:53:09 +02:00
see if the compiler is still running.
One of the mutexes is created in the global name space ( which makes it
possible to access the mutex across user sessions in Windows XP) ; the other
is created in the session name space ( because versions of Windows NT prior
to 4.0 TSE don't have a global name space and don' t support the 'Global\'
prefix) . }
const
MutexName = 'InnoSetupCompilerAppMutex' ;
begin
2015-04-29 13:28:09 +02:00
CreateMutex( MutexName) ;
2023-06-08 11:34:15 +08:00
CreateMutex( 'Global\' + MutexName) ; { don't localize }
2011-10-06 20:53:09 +02:00
end ;
var
InitialCurDir: String ;
procedure CheckParams;
procedure Error;
begin
MessageBox( 0 , SCompilerCommandLineHelp3, SCompilerFormCaption,
MB_OK or MB_ICONEXCLAMATION) ;
Halt( 1 ) ;
end ;
var
P, I: Integer ;
S: String ;
2018-07-15 15:54:03 +02:00
Dummy: Boolean ;
2011-10-06 20:53:09 +02:00
begin
P : = NewParamCount;
I : = 1 ;
while I < = P do begin
S : = NewParamStr( I) ;
if CompareText( S, '/CC' ) = 0 then
CommandLineCompile : = True
else if CompareText( S, '/WIZARD' ) = 0 then begin
if I = P then
Error;
CommandLineWizard : = True ;
CommandLineWizardName : = NewParamStr( I+ 1 ) ;
Inc( I) ;
end
else if CompareText( S, '/ASSOC' ) = 0 then begin
try
2018-07-15 15:54:03 +02:00
RegisterISSFileAssociation( False , Dummy) ;
2011-10-06 20:53:09 +02:00
except
MessageBox( 0 , PChar( GetExceptMessage) , nil , MB_OK or MB_ICONSTOP) ;
Halt( 2 ) ;
end ;
Halt;
end
else if CompareText( S, '/UNASSOC' ) = 0 then begin
try
2025-01-01 02:43:46 -06:00
UnregisterISSFileAssociation( True ) ;
2011-10-06 20:53:09 +02:00
except
MessageBox( 0 , PChar( GetExceptMessage) , nil , MB_OK or MB_ICONSTOP) ;
Halt( 2 ) ;
end ;
Halt;
end
else if ( S = '' ) or ( S[ 1 ] = '/' ) or ( CommandLineFilename < > '' ) then
Error
else
CommandLineFilename : = PathExpand( PathCombine( InitialCurDir, S) ) ;
Inc( I) ;
end ;
if ( CommandLineCompile or CommandLineWizard) and ( CommandLineFilename = '' ) then
Error;
end ;
begin
2025-03-12 22:35:37 +01:00
{$IFNDEF STATICCOMPILER}
2025-04-18 16:35:18 +02:00
try
InitISCmplrLibrary;
2025-04-19 09:48:23 +02:00
except
2025-04-18 16:35:18 +02:00
begin
2025-04-19 09:54:10 +02:00
MessageBox( 0 , PChar( Format( 'Could not load %s: %s' {$IFDEF DEBUG} + #13 #10 #13 #10 'Did you build the ISCmplr project?' {$ENDIF} ,
2025-04-19 15:38:08 +02:00
[ ISCmplrDLL, GetExceptMessage] ) ) , nil , MB_OK or MB_ICONSTOP) ;
2025-04-18 16:35:18 +02:00
Halt( 3 ) ;
end ;
2025-03-12 22:35:37 +01:00
end ;
{$ENDIF}
2025-04-18 16:35:18 +02:00
try
InitIsscintLibrary;
2025-04-19 09:48:23 +02:00
except
2025-04-18 16:35:18 +02:00
begin
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} ,
2025-04-19 15:38:08 +02:00
[ IsscintDLL, GetExceptMessage] ) ) , nil , MB_OK or MB_ICONSTOP) ;
2025-04-18 16:35:18 +02:00
Halt( 4 ) ;
end ;
2025-03-13 08:18:39 +01:00
end ;
2024-11-20 03:15:16 -06:00
{$IFDEF DEBUG}
ReportMemoryLeaksOnShutdown : = True ;
{$ENDIF}
2011-10-06 20:53:09 +02:00
InitialCurDir : = GetCurrentDir;
if not SetCurrentDir( PathExtractDir( NewParamStr( 0 ) ) ) then
SetCurrentDir( GetSystemDir) ;
SetAppUserModelID;
CreateMutexes;
Application. Initialize;
CheckParams;
2012-01-06 16:46:31 +01:00
RegisterApplicationRestart;
2011-10-06 20:53:09 +02:00
2024-12-02 04:25:59 -06:00
if not CommandLineWizard then
Application. MainFormOnTaskBar : = True ;
2011-10-06 20:53:09 +02:00
{ The 'with' is so that the Delphi IDE doesn't mess with these }
with Application do begin
if CommandLineWizard then
Title : = CommandLineWizardName
else
Title : = SCompilerFormCaption;
end ;
2024-08-09 08:43:14 +02:00
Application. CreateForm( TImagesModule, ImagesModule) ;
2024-08-06 18:36:53 +02:00
Application. CreateForm( TMainForm, MainForm) ;
2011-10-06 20:53:09 +02:00
Application. Run;
end .