I've created an iss file which is ForInclude.iss.
Here's how the file looks like:
[Setup]
ShowLanguageDialog=no
[Code]
function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
lpParameters: string; lpDirectory: string; nShowCmd: Integer): THandle;
external 'ShellE...@shell32.dll stdcall';
<event('InitializeSetup')>
function MyInitializeSetup2: Boolean;
var
Instance: THandle;
I: Integer;
S, Params, Language: String;
begin
Result := True;
for I := 1 to ParamCount do
begin
S := ParamStr(I);
if CompareText(Copy(S, 1, 5), '/SL5=') <> 0 then
begin
Params := Params + AddQuotes(S) + ' ';
end;
end;
Params := Params + '/LANG=en';
Language := ExpandConstant('{param:LANG}');
if Language = '' then
begin
Instance := ShellExecute(0, '', ExpandConstant('{srcexe}'), Params, '', SW_SHOW);
if Instance <= 32 then
begin
S := 'Running installer with the selected language failed. Code: %d';
MsgBox(Format(S, [Instance]), mbError, MB_OK);
end;
Result := False;
Exit;
end;
end;
The include that file into the main script like this:
#include <C:\<path_to_iss>\ForInclude.iss>
The problem is as follows:
when I debug my code line by line and Terminate the debugger before the ShellExecute is called then everything is ok and I get *** Setup exit code: 6. But when I do the same with the difference that I Terminate after the ShellExecute has been called then I get
*** Setup is still running; can't get exit code. It looks like the debugger terminates the primary (hidden) instance, but the secondary instance (started by the ShellExecute) keeps running. The only way to stop that instance from running is to kill the process using Windows Task Manager, because the Terminate button in Inno Setup's IDE is no more available.