ExpandConstant('{#SetupSetting("AppName")}') in included files

338 views
Skip to first unread message

Abid Hussain

unread,
May 3, 2021, 2:40:09 AM5/3/21
to innosetup
Hi all,

I have two following files.

setup-base.iss
function GetAppDataDir(Param: String): String;
begin
  Result := ExpandConstant('{autoappdata}\{#SetupSetting("AppName")}');
end;

setup-client.iss
#include "..\setup-client.iss"
#define MyAppName "My App"
[Setup]
AppName={#MyAppName}
[Code]
var
  AppDataDir: String;
procedure InitializeWizard();
begin
  AppDataDir := GetAppDataDir('');
end;

As you see, setup-base.iss is included by setup-client.iss. When the installer is being executed, ExpandConstant('{autoappdata}\{#SetupSetting("AppName")}') evaluates to 'C:\ProgramData\'. 

When {#SetupSetting("AppName")}  is evaluated from inside setup-client.iss everything works fine.

Why does {#SetupSetting("AppName")} evaluates to an empty string?

Regards,
Abid

Abid Hussain

unread,
May 3, 2021, 7:23:17 AM5/3/21
to innosetup

The problem remains but I made a mistake when I pasted the code in the message. The correct code:
setup-base.iss
function GetAppDataDir(Param: String): String;
begin
  Result := ExpandConstant('{autoappdata}\{#SetupSetting("AppName")}');
end;

setup-client.iss
#include "..\setup-base.iss"
#define MyAppName "My App"
[Setup]
AppName={#MyAppName}
[Code]
var
  AppDataDir: String;
procedure InitializeWizard();
begin
  AppDataDir := GetAppDataDir('');
end;

Still the question is, why does {#SetupSetting("AppName")} evaluate to an empty string?

Martijn Laan

unread,
May 3, 2021, 8:21:36 AM5/3/21
to inno...@googlegroups.com
Op 3-5-2021 om 13:23 schreef Abid Hussain:
Why does {#SetupSetting("AppName")} evaluates to an empty string?

Luís César Zanetti

unread,
May 4, 2021, 12:19:54 PM5/4/21
to inno...@googlegroups.com
If possible, move your include line to after preprocessing the AppName line in the setup section.

setup-client.iss
#define MyAppName "My App"
[Setup]
AppName={#MyAppName}
#include "..\setup-base.iss"

[Code]
var
  AppDataDir: String;

procedure InitializeWizard();
begin
  AppDataDir := GetAppDataDir('');
end;
--
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/a265b1f2-01e5-ca1d-0b0a-0d7378a95058%40gmail.com.
Reply all
Reply to author
Forward
0 new messages