1

I have the following tasks as part of my installer:

File Associations

[Tasks]
Name: register32; Description: "Meeting Schedule Assistant (32 bit)"; \
    GroupDescription: "{cm:FileAssociations}"; flags: unchecked exclusive;
Name: register64; Description: "Meeting Schedule Assistant (64 bit)"; \
    GroupDescription: "{cm:FileAssociations}"; Check: IsWin64; Flags: exclusive; 

By design, Inno Setup has UsePreviousTasks set to Yes. However, my software installs both bit editions and the user may subsequently override the installer default via application settings.

Therefore, when my installer is upgrading, can it determine which bit edition is actively registered and leave it set as that value?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Andrew Truckle
  • 17,769
  • 16
  • 66
  • 164

1 Answers1

1

Based on your previous question, I know that your registrations look like:

[HKEY_CLASSES_ROOT\MeetSchedAssist.MWB\Shell\Open\Command]
@="\"C:\\Program Files (x86)\MeetSchedAssist\MeetSchedAssist.exe\" \"%1\""
[HKEY_CLASSES_ROOT\MeetSchedAssist.MWB\Shell\Open\Command]
@="\"C:\\Program Files\MeetSchedAssist\MeetSchedAssist_x64.exe\" \"%1\""

So you can query the registered command and look for a respective executable name in the command.

procedure InitDefaultFileAssociationsTaskValue;
var
  SubKeyName, Command: string;
begin
  SubKeyName := 'MeetSchedAssist.MWB\Shell\Open\Command';
  if not RegQueryStringValue(HKCR, SubKeyName, '', Command) then
  begin
    Log('MWB registration not found');
  end
    else
  begin
    Log(Format('Command registered for MWB is [%s]', [Command]));
    Command := Lowercase(Command);
    if Pos('meetschedassist_x64.exe', Command) > 0 then
    begin
      Log('Detected 64-bit registration');
      WizardSelectTasks('register64');
    end
      else
    if Pos('meetschedassist.exe', Command) > 0 then
    begin
      Log('Detected 32-bit registration');
      WizardSelectTasks('register32');
    end
      else
    begin
      Log('Registration not recognised');
    end;
  end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
  begin
    { Only now is the task list initialized. }
    InitDefaultFileAssociationsTaskValue;
  end;
end;

You may want to modify this to change the task selection only the first time the user enters the tasks page.

var
  SelectTasksVisited: Boolean;

procedure CurPageChanged(CurPageID: Integer);
begin
  if CurPageID = wpSelectTasks then
  begin
    { Only now is the task list initialized. }
    if not SelectTasksVisited then
    begin
      InitDefaultFileAssociationsTaskValue;
      SelectTasksVisited := True;
    end;
  end;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992