1

I need to create a custom uninstall page that let the user choose if he wants to update the software or uninstall it (if the software is already installed).

I have already done my custom page and is like this: enter image description here

How can I get the values of those radio buttons when the user click the Next Button? And, how can I update or uninstall the program?

UPDATE:

procedure InitializeWizard();
var
  InstallPath: String;
  BackgroundBitmapImage: TBitmapImage;
  BmpFileName : String;
  Temp        : String;
  AppId       : String;
  Color       : String;
begin
  AppId:=ExpandConstant('{#AppId}');
  if(AppIsInstalled(AppId, InstallPath)) Then
  begin
      UpdateRemovePageID := RepairRemove_CreatePage(wpWelcome);
  end;

  BmpFileName:= ExpandConstant('{src}\Background.bmp');
  if FileExists(BmpFileName) then begin     
      BackgroundBitmapImage := TBitmapImage.Create(MainForm);         
      BackgroundBitmapImage.Align := alClient;
      BackgroundBitmapImage.Autosize := True;
      BackgroundBitmapImage.Center := True;      
      BackgroundBitmapImage.Bitmap.LoadFromFile(BmpFileName);
  end;  
  BackgroundBitmapImage.BackColor := StringToColor('8cceff');
  BackgroundBitmapImage.Parent  := MainForm;
  WizardForm.Caption := MainForm.Caption;

  if(FileExists(ExpandConstant('{src}\WizImage.bmp'))) then begin


  WizardForm.WizardBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{src}') + '\WizImage.bmp');
  end  
  if(FileExists(ExpandConstant('{src}\WizSmallImage.bmp'))) then begin
      WizardForm.WizardSmallBitmapImage.Bitmap.LoadFromFile(ExpandConstant('{src}') + '\WizSmallImage.bmp');
  end 
end;

function RepairRemove_CreatePage(PreviousPageId: Integer): Integer;
var
    Page: TWizardPage;
    UpdateBmpFileName : String;
    RemoveBmpFileName : String;
begin
    Page := CreateCustomPage(PreviousPageId, ExpandConstant('{cm:RepairRemove_Caption}'), ExpandConstant('{cm:RepairRemove_Description}'));

    BitmapImageUpdate := TBitmapImage.Create(Page);
    UpdateBmpFileName := ExpandConstant('{tmp}\Update.bmp');
    if not FileExists(UpdateBmpFileName) then begin
        ExtractTemporaryFile(ExtractFileName(UpdateBmpFileName));
    end;
    BitmapImageUpdate.Bitmap.LoadFromFile(UpdateBmpFileName);

    with BitmapImageUpdate do
    begin
        Parent := Page.Surface;
        Left := ScaleX(64);
        Top := ScaleY(64);
        Width := ScaleX(32);
        Height := ScaleY(32);
    end;

    Label1 := TLabel.Create(Page);
    with Label1 do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:RepairRemove_Label1_Caption0}');
        Left := ScaleX(120);
        Top := ScaleY(72);
        Width := ScaleX(243);
        Height := ScaleY(13);
    end;

    BitmapImageRemove := TBitmapImage.Create(Page);
    RemoveBmpFileName := ExpandConstant('{tmp}\TrashCan.bmp');
    if not FileExists(RemoveBmpFileName) then begin
        ExtractTemporaryFile(ExtractFileName(RemoveBmpFileName));
    end;
    BitmapImageRemove.Bitmap.LoadFromFile(RemoveBmpFileName);

    with BitmapImageRemove do
    begin
        Parent := Page.Surface;
        Left := ScaleX(64);
        Top := ScaleY(120);
        Width := ScaleX(32);
        Height := ScaleY(32);
    end;

    Label2 := TLabel.Create(Page);
    with Label2 do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('{cm:RepairRemove_Label2_Caption0}');
        Left := ScaleX(120);
        Top := ScaleY(128);
        Width := ScaleX(243);
        Height := ScaleY(13);
    end;

    UpdateButton := TRadioButton.Create(Page);
    with UpdateButton do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('');
        Left := ScaleX(32);
        Top := ScaleY(72);
        Width := ScaleX(17);
        Height := ScaleY(17);
        TabOrder := 0;
    end;

    RemoveButton := TRadioButton.Create(Page);
    with RemoveButton do
    begin
        Parent := Page.Surface;
        Caption := ExpandConstant('');
        Left := ScaleX(32);
        Top := ScaleY(128);
        Width := ScaleX(17);
        Height := ScaleY(17);
        Checked := True;
        TabOrder := 1;
        TabStop := True;
    end;

    with Page do
    begin
        OnActivate := @RepairRemove_Activate;
        OnShouldSkipPage := @RepairRemove_ShouldSkipPage;
        OnBackButtonClick := @RepairRemove_BackButtonClick;
        OnNextButtonClick := @RepairRemove_NextButtonClick;
        OnCancelButtonClick := @RepairRemove_CancelButtonClick;
    end;

    Result := Page.ID;
end;
function RepairRemove_NextButtonClick(Page: TWizardPage): Boolean;
begin
    Result := True;
//What I have to do here to correctly handle the user choice?
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
KingOfMazes
  • 130
  • 1
  • 12

1 Answers1

1

how can I update or uninstall the program?

function RepairRemove_NextButtonClick(Page: TWizardPage): Boolean;
begin
  if RemoveButton.Checked then
  begin
    { Uninstall here }

    { And abort installer }
    ExitProcess(1);
  end;

  Result := True;
end;
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992