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, UninstallLabel1, UninstallFinished1, UninstallFinished2: 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(UninstallProgressForm);
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(ScaleX(610), ScaleY(341), ScaleX(78), ScaleY(27));
UninstallProgressForm.CancelButton.Parent := UninstallProgressForm;
UninstallProgressForm.ProgressBar.SetBounds(ScaleX (100), ScaleY(180), ScaleX(500), ScaleY(20));
UninstallProgressForm.ProgressBar.Parent := UninstallProgressForm;
UninstallLabel := TLabel.Create(UninstallProgressForm);
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(UninstallProgressForm);
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;[/SPOILER]