Есть такой скрипт на создание бэкапа перед установкой и возвратом в исходное состояние после установки
И есть код, как я понимаю, создания прогресс бара
Можно как-то добавить прогресс бар при установке во время резервного копирования и при удалении во время возврата резервных файлов и их удалении?
#define SourceDir "SourceDir";
#define BackupDir "Backup\SourceDir";
[_______________________________________________Code]
procedure CopyFiles(FromPlace, ToPlace: String);
var
ResultCode: Integer;
begin
Exec('xcopy.exe', '/E /C /H /R /Y /F /I ' + AddQuotes(FromPlace) + ' ' + AddQuotes(ToPlace), ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ThereIsFolders: Boolean;
begin
ThereIsFolders := (DirExists(AddBackslash(WizardDirValue()) + '{#SourceDir}') and (not DirExists(AddBackslash(WizardDirValue()) + '{#BackupDir}')) );
if ThereIsFolders then
if CurStep=ssInstall then
begin
WizardForm.ProgressGauge.Hide;
WizardForm.StatusLabel.Caption:='Создание резервных копий файлов...';
CopyFiles(ExpandConstant('{app}') + '\{#SourceDir}\*.*', ExpandConstant('{app}') + '\{#BackupDir}');
WizardForm.ProgressGauge.Show;
WizardForm.StatusLabel.Caption:=SetupMessage(msgStatusExtractFiles);
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
begin
CopyFiles(ExpandConstant('{app}') + '\{#BackupDir}\*.*', ExpandConstant('{app}') + '\{#SourceDir}');
DelTree(ExpandConstant('{app}\Backup'), True, True, True);
end;
end;
#define BackupDir "Backup\SourceDir";
[_______________________________________________Code]
procedure CopyFiles(FromPlace, ToPlace: String);
var
ResultCode: Integer;
begin
Exec('xcopy.exe', '/E /C /H /R /Y /F /I ' + AddQuotes(FromPlace) + ' ' + AddQuotes(ToPlace), ExpandConstant('{app}'), SW_HIDE, ewWaitUntilTerminated, ResultCode);
end;
procedure CurStepChanged(CurStep: TSetupStep);
var
ThereIsFolders: Boolean;
begin
ThereIsFolders := (DirExists(AddBackslash(WizardDirValue()) + '{#SourceDir}') and (not DirExists(AddBackslash(WizardDirValue()) + '{#BackupDir}')) );
if ThereIsFolders then
if CurStep=ssInstall then
begin
WizardForm.ProgressGauge.Hide;
WizardForm.StatusLabel.Caption:='Создание резервных копий файлов...';
CopyFiles(ExpandConstant('{app}') + '\{#SourceDir}\*.*', ExpandConstant('{app}') + '\{#BackupDir}');
WizardForm.ProgressGauge.Show;
WizardForm.StatusLabel.Caption:=SetupMessage(msgStatusExtractFiles);
end;
end;
procedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);
begin
if CurUninstallStep = usPostUninstall then
begin
CopyFiles(ExpandConstant('{app}') + '\{#BackupDir}\*.*', ExpandConstant('{app}') + '\{#SourceDir}');
DelTree(ExpandConstant('{app}\Backup'), True, True, True);
end;
end;
function PBProc(h:hWnd;Msg,wParam,lParam:Longint):Longint;
var
dt,at,pr,i1,i2: Extended;
lt: Longint;
p: string;
tc: DWORD;
begin
Result:=CallWindowProc(PBOldProc,h,Msg,wParam,lParam);
if (Msg=$402) and (WizardForm.ProgressGauge.Position>WizardForm.ProgressGauge.Min) then begin
i1:=WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min;
i2:=WizardForm.ProgressGauge.Max-WizardForm.ProgressGauge.Min;
tc:=GetTickCount;
if tc-eTime>=1000 then begin
dt:=(tc-sTime)/1000;
at:=i2*dt/i1;
lt:=Round(at-dt)
TimeLeft:=LongintToStringTime(lt);
eTime:=tc;
end;
pr:=i1*100/i2;
p:=Format('%f',[pr])+' %. ';
if Length(TimeLeft)>0 then ProgressInfoLabel.Caption:=ExpandConstant('{cm:AllProgress} ')+p+ExpandConstant('{cm:Remains} ')+TimeLeft;
if StatusLabel.Caption<>WizardForm.StatusLabel.Caption then StatusLabel.Caption:=WizardForm.StatusLabel.Caption;
if FileNameLabel.Caption<>WizardForm.FilenameLabel.Caption then FileNameLabel.Caption:=WizardForm.FilenameLabel.Caption;
//Cлайд-шоу по процентам
//Использовать при отключении модуля "FreeArc"
{if pr-OldPosition>=ProgressStep then begin
OldPosition:=OldPosition+ProgressStep;
ImgSetVisibility(AImg[CurrentImage],False);
CurrentImage:=CurrentImage+1;
if CurrentImage>GetArrayLength(AImg)-1 then CurrentImage:=0;
ImgSetVisibility(AImg[CurrentImage],True);
end;}
//Cлайд-шоу по таймеру
//Использовать при подключении модуля "FreeArc"
if GetTickCount-LastTimerEvent>5000{5 секунд} then begin
LastTimerEvent:= GetTickCount;
ImgSetVisibility(AImg[CurrentImage],False);
CurrentImage:=CurrentImage+1;
if CurrentImage=GetArrayLength(AImg) then CurrentImage:=0;
ImgSetVisibility(AImg[CurrentImage],True);
end;
ImgPBSetPosition(NewPB,pr);
ImgApplyChanges(WizardForm.Handle);
end;
end;
var
dt,at,pr,i1,i2: Extended;
lt: Longint;
p: string;
tc: DWORD;
begin
Result:=CallWindowProc(PBOldProc,h,Msg,wParam,lParam);
if (Msg=$402) and (WizardForm.ProgressGauge.Position>WizardForm.ProgressGauge.Min) then begin
i1:=WizardForm.ProgressGauge.Position-WizardForm.ProgressGauge.Min;
i2:=WizardForm.ProgressGauge.Max-WizardForm.ProgressGauge.Min;
tc:=GetTickCount;
if tc-eTime>=1000 then begin
dt:=(tc-sTime)/1000;
at:=i2*dt/i1;
lt:=Round(at-dt)
TimeLeft:=LongintToStringTime(lt);
eTime:=tc;
end;
pr:=i1*100/i2;
p:=Format('%f',[pr])+' %. ';
if Length(TimeLeft)>0 then ProgressInfoLabel.Caption:=ExpandConstant('{cm:AllProgress} ')+p+ExpandConstant('{cm:Remains} ')+TimeLeft;
if StatusLabel.Caption<>WizardForm.StatusLabel.Caption then StatusLabel.Caption:=WizardForm.StatusLabel.Caption;
if FileNameLabel.Caption<>WizardForm.FilenameLabel.Caption then FileNameLabel.Caption:=WizardForm.FilenameLabel.Caption;
//Cлайд-шоу по процентам
//Использовать при отключении модуля "FreeArc"
{if pr-OldPosition>=ProgressStep then begin
OldPosition:=OldPosition+ProgressStep;
ImgSetVisibility(AImg[CurrentImage],False);
CurrentImage:=CurrentImage+1;
if CurrentImage>GetArrayLength(AImg)-1 then CurrentImage:=0;
ImgSetVisibility(AImg[CurrentImage],True);
end;}
//Cлайд-шоу по таймеру
//Использовать при подключении модуля "FreeArc"
if GetTickCount-LastTimerEvent>5000{5 секунд} then begin
LastTimerEvent:= GetTickCount;
ImgSetVisibility(AImg[CurrentImage],False);
CurrentImage:=CurrentImage+1;
if CurrentImage=GetArrayLength(AImg) then CurrentImage:=0;
ImgSetVisibility(AImg[CurrentImage],True);
end;
ImgPBSetPosition(NewPB,pr);
ImgApplyChanges(WizardForm.Handle);
end;
end;