Devils Night,
а такой код
читать дальше »
[Setup]
AppName=MyProg
AppVerName=MyProg
DefaultDirName={pf}\MyProg
DefaultGroupName=MyProg
[code]
var
MyTask: TCheckBox;
function MoveFile(const srcFile, destFile: PChar): Integer; external 'MoveFileA@kernel32.dll stdcall';
procedure CurStepChanged(CurStep: TSetupStep);
var
FindFiles: TFindRec;
i: integer;
MyFiles: array of string;
MyDir, BackDir: string;
begin
if CurStep=ssInstall then begin
if MyTask.Checked then begin
MyFiles:=['TS3.exe','gameplay.package','*.precomp','*.jpg']; // указать файлы или маски нужные для бакупа через запятую. при указании маски '*' бакупятся все файлы с вложенными папками
MyDir:=ExpandConstant('{app}'+'\Game\Bin\'); //папка откуда бакупить
BackDir:=ExpandConstant('{app}'+'\Backup\'); // папка куда бакупить
for i:=0 to GetArrayLength(MyFiles)-1 do
begin
if FindFirst(MyDir+MyFiles[i], FindFiles) then begin
repeat
if not DirExists(BackDir) then begin
CreateDir(BackDir);
end;
MoveFile(MyDir+ FindFiles.Name, BackDir+FindFiles.Name);
until not FindNext(FindFiles);
FindClose(FindFiles);
end;
end;
end;
end;
end;
procedure InitializeWizard();
begin
MyTask:=TCheckBox.Create(WizardForm);
with MyTask do
begin
Parent:=WizardForm.SelectDirPage;
Caption:='Сделать Бэкап';
Left:=ScaleX(0);
Top:=ScaleY(100);
Width:=ScaleX(400);
Height:=ScaleY(15);
TabOrder:=0;
Checked:=True;
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
var
FindFiles: TFindRec;
MyDir, BackDir: string;
begin
if CurUninstallStep = usPostUninstall then begin
MyDir:=ExpandConstant('{app}'+'\Game\Bin\'); //папка куда возвращать файлы
BackDir:=ExpandConstant('{app}'+'\Backup\'); // папка откуда брать файлы
if DirExists(BackDir) then begin
if MsgBox('Восстановить данные из бэкапа?', mbConfirmation, MB_YESNO) = IDYES then begin
if FindFirst(BackDir+'*', FindFiles) then begin
repeat
MoveFile(BackDir+ FindFiles.Name, MyDir+FindFiles.Name);
until not FindNext(FindFiles);
FindClose(FindFiles);
RemoveDir(BackDir);
end;
end;
end;
end;
end;