Вопрос How to create an uninstaller with welcome page, uninstall page and finish page?

  • Автор темы Автор темы nizcoz
  • Дата начала Дата начала

nizcoz

Участник
How to create an uninstaller with welcome page, uninstall page and finish page? Similar to this: (example in spanish)



desinstalación = uninstall
 
Последнее редактирование:
nizcoz,
#define AppID "{D8E8ADA9-2E6C-49E7-924B-A32B89C23A24}"
#define AppName "My Program"
#define AppExeName "MyProg.exe"
#define UnExe "{uninstallexe}"

[Setup]
AppName={#AppName}
AppVerName={#AppName}
DefaultDirName={pf}\{#AppName}
DefaultGroupName={#AppName}
AppId={{#AppID}


[Languages]
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"

[CustomMessages]
spanish.Uninstall=&Desinstalar
spanish.Cancel=&Cancelar
spanish.Alreadyinstalled=El programa {#AppName} ya está instalado

[Code ]
var
Del_Button: TNewButton;
AppPath, UninsPath: string;
ResultCode: Integer;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
Confirm:= False;
end;

procedure UninstallButtonClick(Sender: TObject);
begin
Exec(UninsPath, '', '' , SW_SHOW, ewNoWait, ResultCode);
SendMessage(WizardForm.CancelButton.Handle, $00F5, 0, 0);
end;

procedure InitializeWizard;
begin
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppID}_is1', 'UninstallString', UninsPath) then
UninsPath := RemoveQuotes(UninsPath);
begin
Del_Button := TNewButton.Create(WizardForm);
with Del_Button do
begin
Name := 'Del_Button';
Parent := WizardForm;
Left := ScaleX(25);
Top := ScaleY(327);
Width := ScaleX(75);
Height := ScaleY(23);
Caption:= ExpandConstant('{cm:Uninstall}');
OnClick := @UninstallButtonClick;
end;

if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppID}_is1') then
MsgBox(ExpandConstant('{cm:Alreadyinstalled}'),mbError,MB_OK);
end;
end;

procedure CurPageChanged(CurPageID: Integer);
begin
if RegKeyExists(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#AppID}_is1') and (CurPageId=wpWelcome)
then
begin
Del_Button.Visible := True;
end
else
begin
Del_Button.Visible := false;
end;
end;
 
End: nizcoz, for example thanks El Sanchez, not me. :)
Rus: nizcoz, За пример спасибо El Sanchez, не мне. Это - многостраничный деинсталлятор если что.

Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[Code]
procedure UninsNextButtonOnClick(Sender: TObject);
begin
with UninstallProgressForm.InnerNotebook do
begin
  ActivePage := Pages[ActivePage.PageIndex + 1];      // go to next page
  if ActivePage.PageIndex = PageCount-1 then          // on last page...
begin
  TButton(Sender).Hide;                               // ...hide Next button...
  UninstallProgressForm.Close;                        // ...and close modal form
end;
end;
end;

procedure UninsCancelButtonOnClick(Sender: TObject);
begin
  UninstallProgressForm.ModalResult := mrAbort;
end;

procedure InitializeUninstallProgressForm();
var
  Page: TNewNotebookPage;
  UninsNextButton: TButton;
begin
with UninstallProgressForm do
begin
// create Next button
UninsNextButton := TButton.Create(UninstallProgressForm);
with UninsNextButton do
begin
  Parent := UninstallProgressForm;
  Top := UninstallProgressForm.CancelButton.Top;
  Width := UninstallProgressForm.CancelButton.Width;
  Height := UninstallProgressForm.CancelButton.Height;
  Left := UninstallProgressForm.CancelButton.Left - Width - ScaleX(10);
  Caption := SetupMessage(msgButtonNext);
  OnClick := @UninsNextButtonOnClick;
end;

// modify Cancel button
CancelButton.Enabled := True;
CancelButton.OnClick := @UninsCancelButtonOnClick;
// create custom page
Page := TNewNotebookPage.Create(UninstallProgressForm);
with Page do begin
  Parent := UninstallProgressForm.InnerNotebook;
  Notebook := UninstallProgressForm.InnerNotebook;
  PageIndex := 0; // first page
end;
// set active (first) page
  InnerNotebook.ActivePage := InnerNotebook.Pages[0];
// default page to last page
  InstallingPage.PageIndex := InnerNotebook.PageCount-1;
// show form
  if ShowModal = mrAbort then Abort;
end;
end;
 
Последнее редактирование:
@Nemko
Error with inno 5.5.9 : Unknown identifier ´MODAL RESULT´

Код:
procedure UninsCancelButtonOnClick(Sender: TObject);
begin
  UninstallProgressForm.ModalResult := mrAbort;
end;

@Nemko How to hide all the message box (the first and the last) and add finish page?

I am trying to use this code to hide all the messages box but it does not look good, especially the first message box:

Код:
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PansiChar): HWND; external 'FindWindowExA@user32.dll stdcall';

const
  BM_CLICK    = $00F5;
var
  Timer: TTimer;
  msg: string;
  Wnd, WndEx: HWND;

procedure OnTimer(Sender: TObject);
begin
  Wnd:= FindWindowByWindowName(msg);
  if Wnd > 0 then
    begin
      WndEx:= FindWindowEx(Wnd, 0,'Button', '');
    if WndEx > 0 then
    begin
      PostMessage(WndEx, BM_CLICK, 0, 0);
      Timer.Enabled:= False;
    end;
  end;
end;

function InitializeUninstall:boolean;
//var
//  S: String;
begin
//if ActiveLanguage='rus' then
//  S:= 'Вы действительно хотите удалить {#GameName}'+#10+'и все компоненты программы?'
//else
//  S:= 'Are you sure you want to completely remove {#GameName}'+#10+'and all of its components?';
//if ShowMessageEx(S, '', MB_YESNO, mQuestion) = IDYES then
  Result := True;
  msg:= SetupMessage(msgUninstallAppFullTitle);
  StringChange(msg, '%1', '{#SetupSetting('AppName')}');
  OnTimer(nil);
  Timer:= TTimer.Create(nil);
  with Timer do
  begin
  OnTimer:= @OnTimer;
  Interval:= 1;
  Enabled:= True;
  end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usPostUninstall then
begin
  OnTimer(nil);
  Timer:= TTimer.Create(nil);
  with Timer do
  begin
  OnTimer:= @OnTimer;
  Interval:= 1;
  Enabled:= True;
  end;
end;
end;
 
Последнее редактирование:
nizcoz, sorry, i did not get to do. Too complicated for me.

Код:
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application

[Code]
function FindWindowEx(Parent, Child: HWND; ClassName, WindowName: PansiChar): HWND; external 'FindWindowExA@user32.dll stdcall';

const
  BM_CLICK = $00F5;
var
  Timer: TTimer;
  msg: string;
  Wnd, WndEx: HWND;

procedure UninsNextButtonOnClick(Sender: TObject);
begin
with UninstallProgressForm.InnerNotebook do
begin
  ActivePage := Pages[ActivePage.PageIndex + 1];
  if ActivePage.PageIndex = PageCount-1 then
begin
  TButton(Sender).Hide;
  UninstallProgressForm.Close;
end;
end;
end;

procedure OnTimer(Sender: TObject);
begin
  Wnd:=FindWindowByWindowName(msg);
if Wnd > 0 then
begin
  WndEx := FindWindowEx(Wnd, 0,'Button', '');
  if WndEx > 0 then
begin
  PostMessage(WndEx, BM_CLICK, 0, 0);
  Timer.Enabled:= False;
end;
end;
end;

procedure InitializeUninstallProgressForm();
var
  Page: TNewNotebookPage;
  UninsNextButton: TButton;
begin
with UninstallProgressForm do
begin

UninsNextButton := TButton.Create(UninstallProgressForm);
with UninsNextButton do
begin
  Parent := UninstallProgressForm;
  Top := UninstallProgressForm.CancelButton.Top;
  Width := UninstallProgressForm.CancelButton.Width;
  Height := UninstallProgressForm.CancelButton.Height;
  Left := UninstallProgressForm.CancelButton.Left - Width - ScaleX(10);
  Caption := SetupMessage(msgButtonNext);
  OnClick := @UninsNextButtonOnClick;
end;

CancelButton.Enabled := True;

Page := TNewNotebookPage.Create(UninstallProgressForm);
with Page do begin
  Parent := UninstallProgressForm.InnerNotebook;
  Notebook := UninstallProgressForm.InnerNotebook;
  PageIndex := 0;
end;
  InnerNotebook.ActivePage := InnerNotebook.Pages[0];
  InstallingPage.PageIndex := InnerNotebook.PageCount-1;
  if ShowModal = mrAbort then Abort;
end;
end;

function InitializeUninstall:boolean;
begin
  Result := True;
  msg:= SetupMessage(msgUninstallAppFullTitle);
  StringChange(msg, '%1', '{#SetupSetting('AppName')}');
  OnTimer(nil);
  Timer:= TTimer.Create(nil);
  with Timer do
  begin
  OnTimer:= @OnTimer;
  Interval:= 1;
  Enabled:= True;
end;
end;

procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep=usPostUninstall then
begin
  OnTimer(nil);
  Timer:= TTimer.Create(nil);
  with Timer do
  begin
  OnTimer:= @OnTimer;
  Interval:= 1;
  Enabled:= True;
  end;
end;
end;
 
Назад
Сверху