ZVSRus1957:
Ivan131
Цитата:
[more]
Цитата:
[/more]
Ivan131
Цитата:
Но почему-то бэкап не создаётся. |
[more]
Цитата:
[Setup] AppName=MyProg AppVerName=MyProg DefaultDirName={pf}\MyProg DefaultGroupName=MyProg OutputDir=. //[Files] // Source: "D:\Files\*"; DestDir: "{app}"; Flags: ignoreversion [_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:=['unins000.dat','unins000.exe','*.png']; // указать файлы или маски нужные для бакупа через запятую. при указании маски '*' бакупятся все файлы с вложенными папками MyDir:=ExpandConstant('{app}'+'\'); //папка откуда бакупить 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}'+'\'); //папка куда возвращать файлы 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; |
[/more]