我需要创建一个自定义卸载页面,让用户选择是否要更新软件或卸载它(如果已经安装了软件)。
当用户单击“下一步”按钮时,如何获取这些单选按钮的值? 而且,我该如何更新或卸载该程序?
更新:
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;
答案 0 :(得分:1)
如何更新或卸载该程序?
更新 - 这就是安装程序默认执行的操作。
卸载 - 请参阅How to detect old installation and offer removal?
卸载后您还需要中止安装程序:
Exit from Inno Setup Installation from [code]
function RepairRemove_NextButtonClick(Page: TWizardPage): Boolean;
begin
if RemoveButton.Checked then
begin
{ Uninstall here }
{ And abort installer }
ExitProcess(1);
end;
Result := True;
end;