[Code]
var
CopyInfoLabel, FileInfoLabel: TLabel;
AllSize: Integer;
callback: Longword;
// PathOut - Откуда копировать. Можно указывать маски для копирования, или оставить звездочку и будет копироваться все
// Для копирования отдельных файлов прописываем их в PathOut, и обязательно ставим bInnerFolders как false
// PathIn - Куда копировать
// bInnerFolders - Включать ли подпапки
function isCopyFile(callback: Longword; PathOut, PathIn: String; bInnerFolders: bool): integer; external 'isCopyFile@files:ISCopyFile.dll stdcall';
procedure BreakCopy(); external 'BreakCopy@files:ISCopyFile.dll stdcall';
procedure Button1OnClick(Sender: TObject);
begin
BreakCopy();
end;
function MbOrTb(Float: Extended): String;
begin
if Float/1024 < 1024 then Result:= format('%.2n', [Float/1024])+' МБ' else
Result:= format('%.2n', [Float/(1024*1024)])+' ГБ';
StringChange(Result, ',', '.');
end;
function mCallback( what: PAnsiChar; int1: Longint; str: PAnsiChar): Boolean;
begin
if (string(what) = 'allsize') then
AllSize:= int1;
if(string(what) = 'filename') then
FileInfoLabel.Caption:= MinimizePathName(str, WizardForm.StatusLabel.Font, WizardForm.StatusLabel.Width);
if (string(what) = 'write') then begin
CopyInfoLabel.Caption:= 'Скопировано '+MbOrTb(int1) + ' из ' + MbOrTb(AllSize);
WizardForm.ProgressGauge.Position:= Round(int1);
WizardForm.ProgressGauge.Max:= AllSize;
end;
Application.ProcessMessages;
end;
procedure InitializeWizard();
begin
CopyInfoLabel:= TLabel.Create(WizardForm);
with CopyInfoLabel do begin
Left:= WizardForm.ProgressGauge.Left;
Top:= WizardForm.ProgressGauge.Top+WizardForm.ProgressGauge.Height+ScaleY(10);
Width:= WizardForm.StatusLabel.Width;
Height:= WizardForm.StatusLabel.Height;
AutoSize:= False;
Transparent:= True;
Parent:= WizardForm.InstallingPage;
end;
FileInfoLabel:= TLabel.Create(WizardForm);
with FileInfoLabel do begin
Left:= WizardForm.ProgressGauge.Left;
Top:= WizardForm.ProgressGauge.Top+WizardForm.ProgressGauge.Height+ScaleY(25);
Width:= WizardForm.StatusLabel.Width;
Height:= WizardForm.StatusLabel.Height;
AutoSize:= False;
Transparent:= True;
Parent:= WizardForm.InstallingPage;
end;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
case CurStep of
ssPostInstall: begin
callback:= CallbackAddr('mCallback');
WizardForm.ProgressGauge.Position:= 0;
WizardForm.CancelButton.Enabled:=true;
WizardForm.CancelButton.OnClick:= @Button1OnClick;
repeat
if isCopyFile(callback, {#PathOut}, {#PathIn}, false) <> 1 then break;
if isCopyFile(callback, {#PathOut}, {#PathIn}, false) <> 1 then break;
if isCopyFile(callback, {#PathOut}, {#PathIn}, false) <> 1 then break;
until true;
end;
end;
end;