[Setup]
AppName=My Application
AppVerName=My Application
DefaultDirName={pf}\My Application
[Files]
Source: compiler:Dll Pack\InnoCalback.dll; Flags: dontcopy;
Source: {win}\Fonts\*; DestDir: {app}; Flags: external;
[Languages]
Name: rus; MessagesFile: compiler:Languages\Russian.isl
[CustomMessages]
rus.hour= часов
rus.min= мин
rus.sec= сек
[B][[/B]code]
type
TTimerProc = procedure(HandleW, Msg, idEvent, TimeSys: LongWord);
var
StartInstall: Integer;
TimeLabel, TImeLabel2: TLabel;
TimerID: Longword;
function GetTickCount: DWord;
external 'GetTickCount@kernel32';
function WrapTimerProc(callback: TTimerProc; Paramcount: Integer): longword;
external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): longword;
external 'SetTimer@user32';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
external 'KillTimer@user32 stdcall delayload';
Function cm(Message: String): String;
Begin
Result:= ExpandConstant('{cm:'+ Message +'}')
End;
Function TicksToTime(Ticks: DWord; h,m,s: String; detail: Boolean): String;
Begin
if detail then {hh: mm:ss format}
Result:= PADZ(IntToStr(Ticks/3600000), 2) +':'+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +':'+ PADZ(IntToStr(Ticks/1000 - Ticks/1000/60*60), 2)
else if Ticks/3600 >= 1000 then {more than hour}
Result:= IntToStr(Ticks/3600000) +h+' '+ PADZ(IntToStr((Ticks/1000 - Ticks/1000/3600*3600)/60), 2) +m
else if Ticks/60 >= 1000 then {1..60 minutes}
Result:= IntToStr(Ticks/60000) +m+' '+ IntToStr(Ticks/1000 - Ticks/1000/60*60) +s
else Result:= Format('%.1n', [Abs(Ticks/1000)]) +s {less than one minute}
End;
procedure GetTime(HandleW, Msg, idEvent, TimeSys: LongWord);
var Remaining: Integer;
begin
with WizardForm.ProgressGauge do begin
if position > 0 then Remaining:= trunc((GetTickCount - StartInstall) * Abs((max - position)/position));
TimeLabel.Caption:= 'Осталось ' + TicksToTime(Remaining, cm('hour'), cm('min'), cm('sec'), false);
if (Remaining = 0) then TimeLabel.Caption:= 'Завершение...';
TimeLabel2.Caption:= 'Прошло ' + TicksToTime(GetTickCount - StartInstall, cm('hour'), cm('min'), cm('sec'), false);
end;
end;
procedure InitializeWizard();
begin
TimeLabel:= TLabel.Create(WizardForm)
TimeLabel.SetBounds(ScaleX(0), ScaleY(80), ScaleX(457), ScaleY(20));
TimeLabel.AutoSize:= False
TimeLabel.Transparent:= True;
TimeLabel.Parent:= WizardForm.InstallingPage;
TimeLabel2:= TLabel.Create(WizardForm)
TimeLabel2.SetBounds(ScaleX(0), ScaleY(105), ScaleX(457), ScaleY(20));
TimeLabel2.AutoSize:= False
TimeLabel2.Transparent:= True;
TimeLabel2.Parent:= WizardForm.InstallingPage;
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
If CurStep = ssInstall then
begin
StartInstall:= GetTickCount
TimerID:= SetTimer(0,0, 500, WrapTimerProc(@GetTime, 4))
end;
end;
procedure DeinitializeSetup();
begin
KillTimer(0, TimerID)
end;