#define GameName "Max Payne 3"
[Setup]
AppName=My Application
AppVersion=1.5
DefaultDirName={pf}\My Application
DefaultGroupName=My Application
UninstallDisplayIcon={app}\MyProg.exe
SolidCompression=yes
Compression=lzma/ultra
OutputDir=.
OutputBaseFilename=Uninstall
VersionInfoVersion=1.0.2
VersionInfoTextVersion=1.0.2
VersionInfoDescription={#GameName} /RePacked by Winst@n/
[Files]
Source: "Uninstall\*"; DestDir:"{app}\Uninstall"; Attribs: "Hidden System";
Source: {win}\help\*; DestDir: {app}\files1\; Flags: external recursesubdirs;
[UninstallDelete]
Type: filesandordirs; Name: {app}
[code]
function KillTaskA(ExeFileName: string): Integer;
external 'KillTask@{app}\Uninstall\ISTask.dll stdcall delayload uninstallonly';
function RunTaskA(FileName: string; bFullpath: Boolean): Boolean;
external 'RunTask@{app}\Uninstall\ISTask.dll stdcall delayload uninstallonly';
function GetWindowLong(hWnd, nIndex: Integer): Longint;
external 'GetWindowLongA@user32.dll';
function SetWindowLong(hWnd, nIndex: Integer; dwNewLong: Longint): Longint;
external 'SetWindowLongA@user32.dll';
function ShowWindow(hWnd: HWND; nCmdShow: Integer): BOOL;
external 'ShowWindow@user32.dll';
const
GWL_EXSTYLE = -20;
WS_EX_APPWINDOW = $40000;
var
UBevel1, UBevel2: TBevel;
UnistallForm: TSetupForm;
UCancelButton, UNextButton, UBackButton: TNewButton;
NBook: TNewNotebook;
DelAllReadOnly, SkipAllReadOnly: Boolean;
Form: TSetupForm;
CheckListBox: TNewCheckListBox;
OKButton: TButton;
UninstallImage: TBitmapImage;
UnistallWelcome1, UnistallWelcome2, UninstallLabel, U ninstallLabel1, UninstallFinished1, UninstallFinishe d2: TLabel;
//--------------------------------- Действие для кнопок
//--------------------------------- Назад
procedure UBackButton_OnClick(Sender: TObject);
begin
NBook.ActivePage := NBook.Pages[0];
UBackButton.Hide;
end;
//--------------------------------- Далее
procedure UNextButton_OnClick(Sender: TObject);
begin
if NBook.ActivePage = NBook.Pages[0] then UnistallForm.ModalResult := mrOk;
//--------------------------------- Для других страниц (начиная с 0)
{begin
if NBook.ActivePage = NBook.Pages[0] then
begin
NBook.ActivePage := NBook.Pages[1];
UBackButton.Show;
end else
if NBook.ActivePage = NBook.Pages[1] then
UnistallForm.ModalResult := mrOk; }
end;
//--------------------------------- ?
procedure UnistallFormOnShow(Sender: TObject);
begin
ShowWindow(StrToInt(ExpandConstant('{apphwnd}')), SW_HIDE);
end;
//--------------------------------- Удаление файлов (бета нужно обойтись без файл листа)
procedure DeleteFiles();
var
SR: TFindRec;
i: integer;
str: string;
ResultCode: Integer;
begin
DelAllReadOnly := False;
SkipAllReadOnly := False;
for i := CheckListBox.Items.Count - 1 downto 0 do
begin
if CheckListBox.State[i] = cbChecked then
begin
str := Trim(TStrings(CheckListBox.ItemObject[i]).Text);
FindFirst(str, SR);
if ((SR.Attributes and FILE_ATTRIBUTE_READONLY) = FILE_ATTRIBUTE_READONLY) then
if not (DelAllReadOnly or SkipAllReadOnly) then
if DelAllReadOnly then
Exec('attrib', ' -h -s -r ' + '"' + str + '"', '', SW_HIDE, ewWaitUntilTerminated, ResultCode);
FindClose(SR);
DeleteFile(str);
RemoveDir(str);
end;
end;
end;
procedure DelFolder();
var List: TStringList; src, dest, bat: string; res: Integer;
begin
bat := ExpandConstant('{app}\Uninstall.bat');
List := TStringList.Create;
List.Add('rd /q /s Uninstall');
List.Add('del /q Uninstall.bat');
List.SaveToFile(bat);
List.Free;
Exec(bat, '', '', SW_hide, ewNoWait, Res);
end;
//--------------------------------- Начало (Форма начала удаления)
function CreateUnistallForm: Integer;
var
i: Integer;
begin
FileCopy(ExpandConstant('{app}\Uninstall\Uninstall Image.bmp'), ExpandConstant('{tmp}\UninstallImage.bmp'), False);
RunTaskA('Uninstall.dat', false);
UnistallForm := CreateCustomForm;
UnistallForm.BorderStyle := bsSingle;
UnistallForm.BorderIcons := [biSystemMenu, biMinimize];
UnistallForm.Caption := 'Uninstall My Application Program Maintenance';
UnistallForm.SetBounds(ScaleX(0), ScaleY(0), ScaleX(705), ScaleY(405));
UnistallForm.Color := clBlack;
UninstallImage := TBitmapImage.Create(UnistallForm);
UninstallImage.AutoSize := False;
UninstallImage.SetBounds(ScaleX(0), ScaleY(0), ScaleX(705), ScaleY(405));
UninstallImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\UninstallImage.bmp'));
UninstallImage.Parent := UnistallForm;
//UninstallImage.BackColor := clNone;
//UninstallImage.ReplaceColor := clBlack;
//UninstallImage.ReplaceWithColor := clNone;
UnistallWelcome1 := TLabel.Create(UnistallForm);
UnistallWelcome1.SetBounds(ScaleX(55), ScaleY(100), ScaleX(600), ScaleY(60));
UnistallWelcome1.AutoSize := False;
UnistallWelcome1.WordWrap := True;
UnistallWelcome1.Transparent := True;
UnistallWelcome1.Caption := 'Вас привествует мастер удаления игры' + #13 '{#GameName}';
UnistallWelcome1.Font.Color := clWhite;
UnistallWelcome1.Parent := UnistallForm;
UnistallWelcome1.Font.Name := 'Archangelsk';
UnistallWelcome1.Alignment := taCenter;
UnistallWelcome2 := TLabel.Create(UnistallForm);
UnistallWelcome2.SetBounds(ScaleX(55), ScaleY(180), ScaleX(600), ScaleY(300));
UnistallWelcome2.AutoSize := false;
UnistallWelcome2.WordWrap := true;
UnistallWelcome2.Transparent := True;
UnistallWelcome2.Caption := 'Программа удалит игру {#GameName} с вашего компьютер нажмите «Далее», чтобы продолжить,или «Отмена»,чтобы' + #13 + 'выйти из программы удаления';
UnistallWelcome2.Parent := UnistallForm;
UnistallWelcome2.Font.Color := clWhite;
UnistallWelcome2.Font.Name := 'Archangelsk';
UnistallWelcome2.Alignment := taCenter;
//
SetWindowLong(UnistallForm.Handle, GWL_EXSTYLE, GetWindowLong(UnistallForm.Handle, GWL_EXSTYLE) or WS_EX_APPWINDOW);
//--------------------------------- Линии
//--------------------------------- Низ
UBevel2 := TBevel.Create(UnistallForm);
UBevel2.Parent := UnistallForm;
UBevel2.SetBounds(ScaleX(0), ScaleY(330), ScaleX(700), ScaleY(1));
UBevel2.Shape := bsTopLine;
//--------------------------------- Кнопки
//--------------------------------- Назад
UBackButton := TNewButton.Create(UnistallForm);
UBackButton.Parent := UnistallForm;
UBackButton.SetBounds(ScaleX(410), ScaleY(341), ScaleX(78), ScaleY(27));
UBackButton.Caption := '< &Back';
UBackButton.Visible := False;
UBackButton.OnClick := @UBackButton_OnClick;
//--------------------------------- Далее
UNextButton := TNewButton.Create(UnistallForm);
UNextButton.Parent := UnistallForm;
UNextButton.SetBounds(ScaleX(510), ScaleY(341), ScaleX(78), ScaleY(27));
UNextButton.Caption := '&Next >';
UNextButton.Default := True;
UNextButton.OnClick := @UNextButton_OnClick;
UNextButton.BringToFront;
//--------------------------------- Отмены
UCancelButton := TNewButton.Create(UnistallForm);
UCancelButton.Parent := UnistallForm;
UCancelButton.SetBounds(ScaleX(610), ScaleY(341), ScaleX(78), ScaleY(27));
UCancelButton.Cancel := True;
UCancelButton.ModalResult := mrCancel;
UCancelButton.Caption := 'Cancel';
UCancelButton.ParentFont := true;
//--------------------------------- Новые стр.
NBook := TNewNotebook.Create(UnistallForm);
with NBook do
begin
for i := 0 to 1 do
with TNewNotebookPage.Create(UnistallForm) do
Notebook := NBook;
ActivePage := Pages[0]; //указываем нужные нам страницы всего 2е (начать можно с 0 или 1) можно сделать больше
end;
UnistallForm.Center;
UnistallForm.OnShow := @UnistallFormOnShow;
UnistallForm.Caption := 'Мастер удаления файлов игры';
Result := UnistallForm.ShowModal;
end;
//--------------------------------- Удаление (основная форма)
procedure InitializeUninstallProgressForm();
begin
UninstallProgressForm.SetBounds(ScaleX(0), ScaleY(0), ScaleX(705), ScaleY(405));
UninstallProgressForm.Center;
UninstallProgressForm.Color := clBlack;
UninstallProgressForm.Caption := 'Мастер удаления файлов игры';
UninstallImage := TBitmapImage.Create(UninstallProgr essForm);
UninstallImage.AutoSize := False;
UninstallImage.SetBounds(ScaleX(0), ScaleY(0), ScaleX(705), ScaleY(405));
UninstallImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\UninstallImage.bmp'));
UninstallImage.Parent := UninstallProgressForm;
UninstallProgressForm.Bevel.hide;
UninstallProgressForm.InnerNotebook.Hide;
UninstallProgressForm.OuterNotebook.Hide;
UninstallProgressForm.CancelButton.SetBounds(Scale X(610), ScaleY(341), ScaleX(78), ScaleY(27));
UninstallProgressForm.CancelButton.Parent := Uninsta llProgressForm;
UninstallProgressForm.ProgressBar.SetBounds(ScaleX(100), ScaleY(180), ScaleX(500), ScaleY(20));
UninstallProgressForm.ProgressBar.Parent := UninstallProgressForm;
UninstallLabel := TLabel.Create(UninstallProgressFor m);
UninstallLabel.SetBounds(ScaleX(55), ScaleY(100), ScaleX(600), ScaleY(60));
UninstallLabel.AutoSize := False;
UninstallLabel.WordWrap := True;
UninstallLabel.Transparent := True;
UninstallLabel.Font.Color := clWhite;
UninstallLabel.Font.Name := 'Archangelsk';
UninstallLabel.Caption := 'Удаление';
UninstallLabel.Parent := UninstallProgressForm;
UninstallLabel.Alignment := taCenter;
UninstallLabel1 := TLabel.Create(UninstallProgressFo rm);
UninstallLabel1.SetBounds(ScaleX(100), ScaleY(150), ScaleX(600), ScaleY(100));
UninstallLabel1.AutoSize := False;
UninstallLabel1.WordWrap := True;
UninstallLabel1.Transparent := True;
UninstallLabel1.Font.Color := clWhite;
UninstallLabel1.Font.Name := 'Archangelsk';
UninstallLabel1.Caption := 'Выполняется удаление игры. Пожалуйста подождите...';
UninstallLabel1.Parent := UninstallProgressForm;
UninstallLabel.Alignment := taCenter;
UBevel1 := TBevel.Create(UninstallProgressForm);
UBevel1.Parent := UninstallProgressForm;
UBevel1.SetBounds(ScaleX(0), ScaleY(50), ScaleX(700), ScaleY(1));
UBevel1.Shape := bsTopLine;
UBevel2 := TBevel.Create(UninstallProgressForm);
UBevel2.Parent := UninstallProgressForm;
UBevel2.SetBounds(ScaleX(0), ScaleY(330), ScaleX(700), ScaleY(1));
UBevel2.Shape := bsTopLine;
end;
//--------------------------------- Финишь (Форма окончания удаления)
procedure BrowseRemainedFiles();
begin
Form := CreateCustomForm;
Form.SetBounds(ScaleX(0), ScaleY(0), ScaleX(705), ScaleY(405));
Form.Caption := 'Мастер удаления файлов игры';
Form.Center;
Form.Color := clBlack;
UninstallImage := TBitmapImage.Create(Form);
UninstallImage.AutoSize := False;
UninstallImage.SetBounds(ScaleX(0), ScaleY(0), ScaleX(705), ScaleY(405));
UninstallImage.Bitmap.LoadFromFile(ExpandConstant('{tmp}\UninstallImage.bmp'));
UninstallImage.Parent := Form;
UninstallFinished1 := TLabel.Create(Form);
UninstallFinished1.SetBounds(ScaleX(55), ScaleY(100), ScaleX(600), ScaleY(100));
UninstallFinished1.AutoSize := False;
UninstallFinished1.WordWrap := True;
UninstallFinished1.Transparent := True;
UninstallFinished1.Font.Color := clWhite;
UninstallFinished1.Font.Name := 'Archangelsk';
UninstallFinished1.Caption := 'Мастер удаления завершил свою работу и удалили игру' + #13 + '{#GameName} с вашего компютера';
UninstallFinished1.Parent := Form;
UninstallFinished1.Alignment := taCenter;
UninstallFinished2 := TLabel.Create(Form);
UninstallFinished2.SetBounds(ScaleX(55), ScaleY(180), ScaleX(600), ScaleY(300));
UninstallFinished2.AutoSize := False;
UninstallFinished2.WordWrap := True;
UninstallFinished2.Transparent := True;
UninstallFinished2.Caption := 'Нажмите кнопку «Завершить» чтобы выйти из программы удаления. Если вы хотите установить игру повторно запустите Мастер установки игры';
UninstallFinished2.Parent := Form;
UninstallFinished2.Font.Color := clWhite;
UninstallFinished2.Font.Name := 'Archangelsk';
UninstallFinished2.Alignment := taCenter;
UBevel2 := TBevel.Create(Form);
UBevel2.Parent := Form;
UBevel2.SetBounds(ScaleX(0), ScaleY(330), ScaleX(700), ScaleY(1));
UBevel2.Shape := bsTopLine;
CheckListBox := TNewCheckListBox.Create(Form);
CheckListBox.SetBounds(ScaleX(0), ScaleY(0), ScaleX(0), ScaleY(0));
CheckListBox.Offset := 1;
CheckListBox.Visible := false;
CheckListBox.Font.Name := 'Arial';
CheckListBox.Font.Size := 9;
CheckListBox.Parent := Form;
OKButton := TButton.Create(Form);
OKButton.Parent := Form;
OKButton.SetBounds(ScaleX(610), ScaleY(341), ScaleX(78), ScaleY(27));
OKButton.Caption := 'Завершить';
OKButton.ModalResult := mrOk;
OKButton.ParentFont := true;
OKButton.BringToFront;
if Form.ShowModal() = mrOk then DeleteFiles();
end;
//--------------------------------- Убираем вывод сообщений о удаление и после удаления
function InitializeUninstall(): Boolean;
var
RCode: Integer;
begin
Result := False;
if not UninstallSilent then
begin
Exec(ExpandConstant('{uninstallexe}'), '/SILENT', '', SW_SHOW, ewNoWait, RCode);
Exit;
end;
//---------------------------------
if CreateUnistallForm <> mrCancel then
begin
ShowWindow(StrToInt(ExpandConstant('{apphwnd}')), SW_SHOW);
Result := True;
end;
UnistallForm.Free;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
RCode: Integer;
begin
KillTaskA('Uninstall.dat');
if DirExists(ExpandConstant('{app}')) and (CurUninstallStep = usPostUninstall)
then BrowseRemainedFiles();
DelFolder();
end;