I would like to use code variables to take decision during installation for [Icons]
and [Run]
sections, but I don't know if I'm wrong or not.
My [Code]
section is :
[Code]
var
myW7Val: string;
function GetMyW7Val(Value: string): string;
begin
Result := myW7Val;
end;
function IsWindowsVersionOrNewer(Major, Minor: Integer): Boolean;
var
Version: TWindowsVersion;
begin
GetWindowsVersionEx(Version);
Result :=
(Version.Major > Major) or
((Version.Major = Major) and (Version.Minor >= Minor));
end;
function IsWindows8OrNewer: Boolean;
begin
Result := IsWindowsVersionOrNewer(6, 2);
if not Result then
myW7Val := '1';
myW7Val := '0';
end;
function InitializeSetup: Boolean;
begin
IsWindows8OrNewer
Result := True;
end;
And my [Icons]
section is:
[Icons]
#if "{code:GetMyW7Val}" == '0'
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; \
Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon
#elif "{code:GetMyW7Val}" == '1'
Name: "{autoprograms}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"
Name: "{autodesktop}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: quicklaunchicon
#endif
I would like to use the three first entries if myW7Val
is 0
and the others if myW7Val
is 1
. But for the moment I have a mistake and no values.
Do you have any ideas?
Thanks in advance
To answer your literal question, use the Check
parameter:
[Code]
function IsWindows8OrNewer: Boolean;
begin
Result := IsWindowsVersionOrNewer(6, 2);
end;
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Check: not IsWindows8OrNewer
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Tasks: desktopicon; Check: not IsWindows8OrNewer
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; \
Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; \
Check: not IsWindows8OrNewer
Name: "{autoprograms}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Check: IsWindows8OrNewer
Name: "{autodesktop}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: desktopicon; \
Check: IsWindows8OrNewer
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: quicklaunchicon; \
Check: IsWindows8OrNewer
Though that's an overkill, there are MinVersion
and OnlyBelowVersion
parameters for selecting entries for specific Windows versions:
[Icons]
Name: "{autoprograms}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
OnlyBelowVersion: 6.2
Name: "{autodesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
Tasks: desktopicon; OnlyBelowVersion: 6.2
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppName}"; \
Filename: "{app}\{#MyAppExeName}"; Tasks: quicklaunchicon; \
OnlyBelowVersion: 6.2
Name: "{autoprograms}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; MinVersion: 6.2
Name: "{autodesktop}\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: desktopicon; \
MinVersion: 6.2
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{#MyAppLanceurName}"; \
Filename: "{app}\{#MyAppLanceurExeName}"; Tasks: quicklaunchicon; MinVersion: 6.2
Alternatively, you can use a scripted constant to select application name and filename, to avoid having to duplicate the Icons
entries:
[Code]
function IsWindows8OrNewer: Boolean;
begin
Result := IsWindowsVersionOrNewer(6, 2);
end;
function GetAppName(Param: string): string;
begin
if IsWindows8OrNewer then Result := '{#MyAppLanceurName}'
else Result := '{#MyAppName}';
end;
function GetAppExeName(Param: string): string;
begin
if IsWindows8OrNewer then Result := '{#MyAppLanceurExeName}'
else Result := '{#MyAppExeName}';
end;
[Icons]
Name: "{autoprograms}\{code:GetAppName}"; Filename: "{app}\{code:GetAppExeName}"
Name: "{autodesktop}\{code:GetAppName}"; Filename: "{app}\{code:GetAppExeName}"; \
Tasks: desktopicon
Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\{code:GetAppName}"; \
Filename: "{app}\{code:GetAppExeName}"; Tasks: quicklaunchicon