Possible IDE bug

222 views
Skip to first unread message

JConstantine

unread,
Dec 21, 2020, 9:41:34 AM12/21/20
to innosetup
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.


mpri...@gmail.com

unread,
Dec 21, 2020, 11:35:08 AM12/21/20
to innosetup
I'd clarify it a bit: When the debugger steps over the ShellExecute and the new instance of the installer process is started, the IDE debugger seems to pick that process and restarts the debugging. I assume this is not intended behaviour, or at least not a well-tested one. The Terminate function then probably tries to close/communicate with to the old process (which has terminated on its own meanwhile – due to its InitializeSetup returning False after the  ShellExecute). 

mpri...@gmail.com

unread,
Dec 21, 2020, 11:35:38 AM12/21/20
to innosetup

Martijn Laan

unread,
Dec 21, 2020, 12:53:35 PM12/21/20
to inno...@googlegroups.com
This script is the most hacky script I've seen in a long whole. It can't seriously be expected that this is supported in any way. Calling this a bug is just plain wrong.

The built-in ShellExec already disallows restarting Setup and this script makes me think importing ShellExecute to get around this should probably be blocked as well.

Greetings,
Martijn

Op 21 dec. 2020 om 17:35 heeft mpri...@gmail.com <mpri...@gmail.com> het volgende geschreven:

I'd clarify it a bit: When the debugger steps over the ShellExecute and the new instance of the installer process is started, the IDE debugger seems to pick that process and restarts the debugging. I assume this is not intended behaviour, or at least not a well-tested one. The Terminate function then probably tries to close/communicate with to the old process (which has terminated on its own meanwhile – due to its InitializeSetup returning False after the  ShellExecute). 

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/3a404a42-6b8e-4a80-9f5a-e87dce702fben%40googlegroups.com.

Martijn Laan

unread,
Dec 21, 2020, 3:02:22 PM12/21/20
to inno...@googlegroups.com


> Op 21 dec. 2020 om 15:41 heeft JConstantine <jsho...@gmail.com> het volgende geschreven:
>
> if CompareText(Copy(S, 1, 5), '/SL5=')

/SL5 is not the only internal parameter so this bit is wrong and your script is breaking the communication between the IDE and Setup.

But the entire approach is flawed to begin with since these parameters are undocumented and therefore can not and should not be relied on.

You should post about what you're trying to achieve instead.

Greetings,
Martijn

JConstantine

unread,
Dec 22, 2020, 2:33:09 AM12/22/20
to innosetup
What I'm trying to achieve is the first answer to the following question on StackOverflow:
https://stackoverflow.com/questions/41021292/inno-setup-language-selector-with-vcl-styles

понедельник, 21 декабря 2020 г. в 22:02:22 UTC+2, Martijn Laan:

JConstantine

unread,
Dec 22, 2020, 3:42:56 AM12/22/20
to innosetup
All has started from this question of mine:
https://stackoverflow.com/questions/61057772/can-i-swap-issi-splashscreen-and-language-selection-dialog-in-inno-setup

вторник, 22 декабря 2020 г. в 09:33:09 UTC+2, JConstantine:

Martijn Laan

unread,
Mar 25, 2021, 2:00:37 PM3/25/21
to inno...@googlegroups.com, mpri...@gmail.com
Op 21-12-2020 om 21:02 schreef Martijn Laan:
Op 21 dec. 2020 om 15:41 heeft JConstantine <jsho...@gmail.com> het volgende geschreven:

   if CompareText(Copy(S, 1, 5), '/SL5=')
/SL5 is not the only internal parameter so this bit is wrong and your script is breaking the communication between the IDE and Setup.

In the next version support functions ParamCount and ParamStr exclude special internal parameters used by Setup, such as /SL5= and /DEBUGWND=. So with the next version the bad script (https://stackoverflow.com/q/65389216/850848) simply won't see these parameters so it can't pass them on either.

Note that GetCmdTail still *does* include the special internal parameters.

Greetings,
Martijn Laan

mpri...@gmail.com

unread,
Mar 26, 2021, 5:17:49 AM3/26/21
to innosetup

Martijn Laan

unread,
Mar 26, 2021, 4:51:29 PM3/26/21
to inno...@googlegroups.com
Op 26-3-2021 om 10:17 schreef mpri...@gmail.com:
Thanks. The update isn't entirely correct though:

/DETACHEDMSG and
/DebugSpawnServer are regular parameters that the user needs to specify on the command lines. So they will never appear 'out of thin air' unlike /SL5= etc.

The reason that they're undocumented in the help file is that they're only useful to Inno Setup programmers.

Greetings,
Martijn

mpri...@gmail.com

unread,
Mar 28, 2021, 4:47:06 AM3/28/21
to innosetup
OK, I've updated the answer.
Reply all
Reply to author
Forward
0 new messages