forked from jrsoftware/issrc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCompil32.dpr
183 lines (165 loc) · 5.26 KB
/
Compil32.dpr
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
program Compil32;
{
Inno Setup
Copyright (C) 1997-2010 Jordan Russell
Portions by Martijn Laan
For conditions of distribution and use, see LICENSE.TXT.
Compiler
}
uses
SafeDLLPath in 'SafeDLLPath.pas',
Windows,
SysUtils,
Forms,
PathFunc,
CompForm in 'CompForm.pas' {CompileForm},
CmnFunc in 'CmnFunc.pas',
CmnFunc2 in 'CmnFunc2.pas',
CompMsgs in 'CompMsgs.pas',
CompInt in 'CompInt.pas',
CompOptions in 'CompOptions.pas' {OptionsForm},
CompStartup in 'CompStartup.pas' {StartupForm},
CompWizard in 'CompWizard.pas' {WizardForm},
CompWizardFile in 'CompWizardFile.pas' {WizardFileForm},
CompFileAssoc in 'CompFileAssoc.pas',
TmSchemaISX in '..\Components\TmSchemaISX.pas',
UxThemeISX in '..\Components\UxThemeISX.pas',
DebugStruct in 'DebugStruct.pas',
BrowseFunc in 'BrowseFunc.pas',
CompSignTools in 'CompSignTools.pas' {SignToolsForm},
ScintInt in '..\Components\ScintInt.pas',
ScintEdit in '..\Components\ScintEdit.pas',
ScintStylerInnoSetup in '..\Components\ScintStylerInnoSetup.pas';
{$R *.res}
{$R Compil32.manifest.res}
{$R CompDocIcon.res}
procedure SetAppUserModelID;
var
Func: function(AppID: PWideChar): HRESULT; stdcall;
begin
{ On Windows 7, 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. }
Func := GetProcAddress(GetModuleHandle('shell32.dll'),
'SetCurrentProcessExplicitAppUserModelID');
if Assigned(Func) then
Func('JR.InnoSetup.IDE.5');
end;
procedure RegisterApplicationRestart;
const
RESTART_MAX_CMD_LINE = 1024;
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;
CommandLine: WideString;
begin
{ Allow Restart Manager to restart us after updates. }
Func := GetProcAddress(GetModuleHandle('kernel32.dll'),
'RegisterApplicationRestart');
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;
if Length(CommandLine) > RESTART_MAX_CMD_LINE then
CommandLine := '';
Func(PWideChar(CommandLine), RESTART_NO_CRASH or RESTART_NO_HANG or RESTART_NO_REBOOT);
end;
end;
procedure CreateMutexes;
{ Creates the two mutexes used by the Inno Setup's own installer/uninstaller to
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
CreateMutex(MutexName);
CreateMutex('Global\' + MutexName); { don't localize }
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;
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
RegisterISSFileAssociation;
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
UnregisterISSFileAssociation;
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
InitialCurDir := GetCurrentDir;
if not SetCurrentDir(PathExtractDir(NewParamStr(0))) then
SetCurrentDir(GetSystemDir);
SetAppUserModelID;
CreateMutexes;
Application.Initialize;
CheckParams;
RegisterApplicationRestart;
{ 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;
Application.CreateForm(TCompileForm, CompileForm);
Application.Run;
end.