Вопрос Example scripts to show......

nizcoz

Участник
I need examples to show:

1)elapsed time, remaining time, etc. (to show this at inno 5.5.1 uu2, i have got the code to show at 5.5.9)
2)to resize the progress bar.
 

nizcoz

Участник
I am trying to extract of this code only what is needed to show elapsed time, percentage, etc (without isdone, simple code), but i can not. Is this possible?

Код:
var
ElapsedTimeLbl,Percentuale,RollingBack,TimelBL,LabelCurrFileName: TLabel;
ISDoneCancel:integer;
ISDoneError:boolean;
CancelBtn: TButton;
PBOldProc     : Longint;
WFCaption     : string;
eTime, sTime  : DWORD;

type
#ifdef UNICODE
 PChar = PAnsiChar;
#endif
TCallback = function (OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:pAnsiChar): longword;
TPBProc = function (h:hWnd;Msg,wParam,lParam:Longint):Longint;


function SetWindowLong(hWnd: HWND; nIndex: Integer; dwNewLong: Longint): Longint; external 'SetWindowLongA@user32.dll stdcall';
function CallBackProc(P:TPBProc;ParamCount:integer):LongWord; external 'wrapcallbackaddr@files:CallbackCtrl.dll stdcall';
function CallWindowProc(lpPrevWndFunc: Longint; hWnd: HWND; Msg: UINT; wParam, lParam: Longint): Longint; external 'CallWindowProcA@user32.dll stdcall';
function GetTickCount: DWORD; external 'GetTickCount@kernel32.dll stdcall';
function WrapCallback(callback:TCallback; paramcount:integer):longword;external 'wrapcallback@files:ISDone.dll stdcall delayload';
function ISDoneInit(RecordFileName:AnsiString; TimeType,Comp1,Comp2,Comp3:Cardinal; WinHandle, NeededMem:longint; callback:TCallback):boolean; external 'ISDoneInit@files:ISDone.dll stdcall';
function ISArcExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath, ExtractedPath: AnsiString; DeleteInFile:boolean; Password, CfgFile, WorkPath: AnsiString; ExtractPCF: boolean ):boolean; external 'ISArcExtract@files:ISDone.dll stdcall delayload';
function IS7ZipExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password: AnsiString):boolean; external 'IS7zipExtract@files:ISDone.dll stdcall delayload';
function ISRarExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password: AnsiString):boolean; external 'ISRarExtract@files:ISDone.dll stdcall delayload';
function ISPrecompExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile: AnsiString; DeleteInFile:boolean):boolean; external 'ISPrecompExtract@files:ISDone.dll stdcall delayload';
function ISSRepExtract(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile: AnsiString; DeleteInFile:boolean):boolean; external 'ISSrepExtract@files:ISDone.dll stdcall delayload';
function ISxDeltaExtract(CurComponent:Cardinal; PctOfTotal:double; minRAM,maxRAM:integer; InName, DiffFile, OutFile: AnsiString; DeleteInFile, DeleteDiffFile:boolean):boolean; external 'ISxDeltaExtract@files:ISDone.dll stdcall delayload';
function ISPackZIP(CurComponent:Cardinal; PctOfTotal:double; InName, OutFile: AnsiString;ComprLvl:integer; DeleteInFile:boolean):boolean; external 'ISPackZIP@files:ISDone.dll stdcall delayload';
function ShowChangeDiskWindow(Text, DefaultPath, SearchFile:AnsiString):boolean; external 'ShowChangeDiskWindow@files:ISDone.dll stdcall delayload';
function Exec2 (FileName, Param: PAnsiChar;Show:boolean):boolean; external 'Exec2@files:ISDone.dll stdcall delayload';
function ISFindFiles(CurComponent:Cardinal; FileMask:AnsiString; var ColFiles:integer):integer; external 'ISFindFiles@files:ISDone.dll stdcall delayload';
function ISPickFilename(FindHandle:integer; OutPath:AnsiString; var CurIndex:integer; DeleteInFile:boolean):boolean; external 'ISPickFilename@files:ISDone.dll stdcall delayload';
function ISGetName(TypeStr:integer):pAnsichar; external 'ISGetName@files:ISDone.dll stdcall delayload';
function ISFindFree(FindHandle:integer):boolean; external 'ISFindFree@files:ISDone.dll stdcall delayload';
function ISExec(CurComponent:Cardinal; PctOfTotal,SpecifiedProcessTime:double; ExeName,Parameters,TargetDir,OutputStr:AnsiString;Show:boolean):boolean; external 'ISExec@files:ISDone.dll stdcall delayload';
function SrepInit(TmpPath:pAnsiChar;VirtMem,MaxSave:Cardinal):boolean; external 'SrepInit@files:ISDone.dll stdcall delayload';
function PrecompInit(TmpPath:pAnsiChar;VirtMem:cardinal;PrecompVers:single):boolean; external 'PrecompInit@files:ISDone.dll stdcall delayload';
function FileSearchInit(RecursiveSubDir:boolean):boolean; external 'FileSearchInit@files:ISDone.dll stdcall delayload';
function ISDoneStop:boolean; external 'ISDoneStop@files:ISDone.dll stdcall';
function ChangeLanguage(Language:AnsiString):boolean; external 'ChangeLanguage@files:ISDone.dll stdcall delayload';
function SuspendProc:boolean; external 'SuspendProc@files:ISDone.dll stdcall';
function ResumeProc:boolean; external 'ResumeProc@files:ISDone.dll stdcall';

function ProgressCallback(OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:pAnsiChar): longword;
begin
if OveralPct<=Wizardform.ProgressGauge.Max then
Wizardform.Progressgauge.Position := OveralPct;
Result := ISDoneCancel;
ElapsedTimeLbl.Caption:=ExpandConstant('{cm:ETime}')+' '+TimeStr2;
with WizardForm.ProgressGauge do begin
LabelCurrFileName.Caption:=SetupMessage(msgStatusExtractFiles)+': '+MinimizePathName(CurrentFile, LabelCurrFileName.Font, LabelCurrFileName.Width-ScaleX(100));
end;
end;

function LongintToStringTime(t:Longint):string;
var
h,m,s:integer;
begin
h:=t div 3600;
t:=t-h*3600;
m:=t div 60;
s:=t-m*60;
Result:='';
if h>0 then Result:=Result+IntToStr(h)+ ExpandConstant(' {cm:ORE} ');
if (m>0) or (h>0) then Result:=Result+IntToStr(m)+ExpandConstant(' {cm:MINUTI} ');
if (m>0) or (h>0) or (s>0) then Result:=Result+IntToStr(s)+ExpandConstant(' {cm:SECONDI} ');
end;

function PBProc(h:hWnd;Msg,wParam,lParam:Longint):Longint;
var
R:Longint;
dt,at,pr,i1,i2:Extended;
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;
R:=Round(at-dt)
TimelBL.Caption:=ExpandConstant(' {cm:RIMANENTE} ')+LongintToStringTime(R);
eTime:=tc;
end;
pr:=i1*100/i2;
p:=' Percent ['+Format('%f',[pr])+'%]';
StringChange(p,',','.');
Percentuale.Caption:=WFCaption+p;
end;
end;

procedure AllCancel;
begin
SetWindowLong(WizardForm.ProgressGauge.Handle,-4,PBOldProc);
Percentuale.Caption:=WFCaption;
end;

procedure CancelButtonOnClick(Sender: TObject);
begin
SuspendProc;
RollingBack.Show;
if MsgBox(SetupMessage(msgExitSetupMessage), mbConfirmation, MB_YESNO) = IDYES then ISDoneCancel:=1;
ResumeProc;
RollingBack.Hide;
end;

procedure HideControls;
begin
CancelBtn.Hide;
LabelCurrFileName.Hide;
TimelBL.Hide;
RollingBack.Hide;
end;

procedure InitializeWizard();
begin

WizardForm.ProgressGauge.Top := ScaleY(46);
RollingBack := TLabel.Create(WizardForm);
with RollingBack do begin
Caption:=SetupMessage(msgStatusRollback);
Parent := WizardForm;
Font.Color := clred;
Font.Height := 15;
Font.Name := 'Tahoma';
Font.Style := [];
ParentFont := False;
SetBounds(ScaleX(190),ScaleY(330),ScaleX(173),ScaleY(72));
end;
CancelBtn := TButton.Create(WizardForm);
with CancelBtn do begin
Name := 'Cancel';
Parent := WizardForm;
Left := WizardForm.CancelButton.Left;
Top := WizardForm.CancelButton.Top;
Width := WizardForm.CancelButton.Width;
Height := WizardForm.CancelButton.Height;
OnClick:=@CancelButtonOnClick;
Font.Size:=8;
Font.Name:='calibri';
end;
TimelBL:=TLabel.Create(WizardForm);
with TimelBL do begin
Parent:=WizardForm.InstallingPage;
AutoSize:=False;
SetBounds(180,70,200,14);
Font.Size:=8;
Font.Name:='calibri';
end;
LabelCurrFileName := TLabel.Create(WizardForm);
with LabelCurrFileName do begin
Parent   := WizardForm.InstallingPage;
AutoSize := False;
Width    := WizardForm.ProgressGauge.Width+ScaleX(30);
Left     := ScaleX(0);
Top      := ScaleY(30);
Font.Size:=8;
Font.Name:='calibri';
end;
Percentuale := TLabel.Create(WizardForm);
with Percentuale do begin
Parent   := WizardForm.InstallingPage;
AutoSize := False;
SetBounds(0,70,WizardForm.ClientWidth-40,21);
Font.Size:=8;
Font.Name:='calibri';
end;
ElapsedTimeLbl := TLabel.Create(WizardForm);
with ElapsedTimeLbl do begin
Parent   := WizardForm.FinishedPage;
AutoSize := False;
Width    := 300;
Left     := 180;
Top      := 200;
Font.Size:=10;
Font.Name:='calibri';
Font.Color:=clBlue;
end;
end;

procedure CurPageChanged(CurPageID: integer);
begin
HideControls;
if CurPageID=wpWelcome then
begin
end;
if CurPageID=wpSelectDir then
begin
end;

if CurPageID=wpInstalling then
begin
CancelBtn.Show;
LabelCurrFileName.Show;
TimelBL.Show;
end;

if CurPageID=wpFinished then
begin
TimelBL.Hide;
AllCancel;
HideControls;
end;

if (CurPageID = wpFinished) and ISDoneError then
begin
WizardForm.Caption:= SetupMessage(msgErrorTitle);
WizardForm.FinishedLabel.Font.Color:= clRed;
WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted);
end;
end;

function CheckError:boolean;
begin
result:= not ISDoneError;
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
res, i, ResultCode: integer;
Arc1, Arc2: Array of String;
begin

If CurStep = ssInstall then begin
WizardForm.StatusLabel.Caption:=SetupMessage(msgStatusExtractFiles);

sTime:=GetTickCount;
eTime:=sTime;
PBOldProc:=SetWindowLong(WizardForm.ProgressGauge.Handle,-4,CallBackProc(@PBProc,4));

#ifdef PrecompInside
ExtractTemporaryFile('CLS-precomp.dll');
ExtractTemporaryFile('packjpg_dll.dll');
ExtractTemporaryFile('packjpg_dll1.dll');
ExtractTemporaryFile('precomp.exe');
ExtractTemporaryFile('zlib1.dll');
ExtractTemporaryFile('facompress.dll');
#endif
#ifdef SrepInside
ExtractTemporaryFile('CLS-srep.dll');
#endif
#ifdef MSC
ExtractTemporaryFile('CLS-MSC.dll');
#endif
ExtractTemporaryFile('arc.ini');
ExtractTemporaryFile('unarc.dll');
ExtractTemporaryFile('English.ini');

ISDoneError:=false;
i:=1;
if (GetIniString('FreearcFile' + IntToStr(i),'Archive','',ExpandConstant('{tmp}\Setup.ini')) <> '') then
begin
WizardForm.ProgressGauge.Max:=0;
repeat
WizardForm.ProgressGauge.Max:= WizardForm.ProgressGauge.Max + 1000;
i:= i + 1;
until (GetIniString('FreearcFile' + IntToStr(i),'Archive','',ExpandConstant('{tmp}\Setup.ini')) = '');
end;
if ISDoneInit(ExpandConstant('{tmp}\records.inf'), $F777, 0,0,0, MainForm.Handle, 512, @ProgressCallback) then begin
repeat
ChangeLanguage('English');
if not SrepInit('',512,0) then ISDoneError := True;
if not PrecompInit('',128,0) then ISDoneError := True;
if not FileSearchInit(true) then ISDoneError := True;
i:=1;
if (GetIniString('FreearcFile' + IntToStr(i),'Archive','',ExpandConstant('{tmp}\Setup.ini')) <> '') then
begin
SetArrayLength(Arc1,4);
SetArrayLength(Arc2,4);
repeat
Arc1[0]:=ExpandConstant(GetIniString('FreearcFile' + IntToStr(i),'Archive','',ExpandConstant('{tmp}\Setup.ini')));
Arc1[1]:=ExpandConstant(GetIniString('FreearcFile' + IntToStr(i),'Output','',ExpandConstant('{tmp}\Setup.ini')));
Arc1[2]:=ExpandConstant(GetIniString('FreearcFile' + IntToStr(i),'Disk','1',ExpandConstant('{tmp}\Setup.ini')));
if Arc1[0] <> '' then
begin
if not FileExists(Arc1[0]) then
begin
if MsgBox(SetupMessage(msgChangeDiskTitle) +'  '+'( '+ Arc1[2]+' )', mbError, MB_OKCANCEL) = IDCANCEL then ISDoneError := True;
end else begin
if not ISArcExtract( 0, 0, Arc1[0], Arc1[1], '', false, Arc1[3], ExpandConstant('{tmp}\arc.ini'), ExpandConstant('{app}'), False) then ISDoneError := True;
i:= i + 1;
end;
end;
until ((GetIniString('FreearcFile' + IntToStr(i),'Archive','',ExpandConstant('{tmp}\Setup.ini')) = '') or (ISDoneError = True));
end;
until true;
ISDoneStop;
end;
AllCancel;
HideControls;
WizardForm.ProgressGauge.Hide;
end;
if (CurStep=ssPostInstall) and ISDoneError then begin
Exec(ExpandConstant('{uninstallexe}'), '/VERYSILENT','', sw_Hide, ewWaitUntilTerminated, ResultCode);
end;
end;

function InitializeSetup: Boolean;
var
Uninstall,Location: string;
ResultCode: Integer;
begin
if not FileExists(ExpandConstant('{tmp}\CallbackCtrl.dll')) then ExtractTemporaryFile('CallbackCtrl.dll');
ExtractTemporaryFile('Setup.ini');
if RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppName}_is1','UninstallString', Uninstall) then
Uninstall:=RemoveQuotes(Uninstall);
begin
if not Exec(Uninstall, ' /SILENT', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
RegQueryStringValue(HKLM, 'Software\Microsoft\Windows\CurrentVersion\Uninstall\{#MyAppName}_is1','InstallLocation', Location);
end;
Result:=True;
end;
 
Сверху