I need the installer to show different AppName
based on (un)selected components. I tried this:
[Setup]
AppName={code:GetAppName}
AppVersion=1.0
AppVerName=Dagon Video Tools
AppId=Dagon Video Tools
DefaultDirName={sd}\Games\Dagon Video Tools
[Code]
function GetAppName(Value: string): string;
var
CurPageID: Integer;
Begin
Result := 'Dagon Video Tools'
if (CurPageID=wpSelectComponents) and IsComponentSelected('Slasher') and not IsComponentSelected('Frankenstein') then
begin
Result := 'Dagon Slasher';
end;
if (CurPageID=wpSelectComponents) and IsComponentSelected('Frankenstein') and not IsComponentSelected('Slasher') then
begin
Result := 'Dagon Frankenstein';
end;
if (CurPageID=wpSelectComponents) and IsComponentSelected('Slasher') and IsComponentSelected('Frankenstein') then
begin
Result := 'Dagon Video Tools';
end;
End;
But, as you can guess, this doesn't work. Is this script incomplete or should it be done in a different way altogether?
The
AppName
directive value is resolved (= yourGetAppName
is called) immediately after theInitializeSetup
(if any) finishes. That is a long before the user is able to change the components.So you cannot make
AppName
depend on the selected components.Some uses of the
AppName
could be overridden with a custom value though, but not all. See below.Though, as I know that your question is actually about a setup type, you can do this:
/APPTYPE=slasher
) and exit./APPTYPE
, you know from the beginning, what component/type you are installing and hence you can set theAppName
normally.This is actually a way simpler to implement. The only drawback is that the setup window is "recreated" after the user selects the "type".
This is the original response in case you do not want to use the above solution.
First, your implementation of the
GetAppName
is wrong. You are using an uninitialized variableCurPageID
. And anyway, as mentioned already, theGetAppName
is called even before the wizard window is created, so "current page" is irrelevant here.The correct implementation would be like:
But this still won't make it working in the
AppName
directive. We will use it in other contexts though later.Also note that for your specific installer, you should better use the
WizardSetupType(false)
function instead of theIsComponentSelected
.FinishedLabel
Just override the Inno Setup default text in
CurPageChanged(wpFinished)
:Add/Remove Programs
That's easy. There's the
UninstallDisplayName
directive for this, which is resolved only during the actual installation, when we already know the selected components. So we can use your (fixed)GetAppName
here:Are you sure you want to completely remove
AppName
and all of its components?You cannot change that. You better use some generic name in the
AppName
so that this message works for any component.Or make the message not mention the application name at all:
Alternatively remove the message completely:
Can I disable uninstall confirmation message?
and optionally replace it with your own message implemented in the
InitializeUninstall
event function.Please wait while
AppName
is removed from your computerThe same solution as for the
WizardForm.FinishedLabel
. Just use theUninstallProgressForm.PageDescriptionLabel
from theInitializeUninstallProgressForm
.AppName
was successfully removed from your computerSimilar as with the "Are you sure you want to completely remove
AppName
and all of its components?"Either make the
AppName
generic. Or disable the message with "silent" mode and implement your own message in theCurUninstallStepChanged(usPostUninstall)
.For a similar discussion, see also Changing AppName and AppDir depending on language in Inno Setup.