Inno setup + isdone计时器

时间:2014-09-13 22:03:29

标签: inno-setup

帮助修改时间我没有多少时间剩下并且安装的时间已经出现在页面上状态必须出现在页面安装我在这里上网站脚本时间可以有人检查我的脚本并指出错误我使用的脚本是更多时间我想要的样本图像我无法发布完整的脚本。下载链接已满

enter link description here

enter image description here

[Code]
////////////////////////////////////ISDONE///////////////////////////
const
  PCFonFLY=true;
  notPCFonFLY=false;
var
  LabelPct1,LabelCurrFileName,LabelTime1,LabelTime2: TLabel;  //Desativa - LabelTime3
  ISDoneProgressBar1: TNewProgressBar;
  MyCancelButton: TButton;
  ISDoneCancel:integer;
  ISDoneError:boolean;
  PCFVer:double;

type
  TCallback = function (OveralPct,CurrentPct: 
integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;

function WrapCallback(callback:TCallback; paramcount:integer):longword;external 
'wrapcallback@files:ISDone.dll stdcall delayload';

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 ISDoneInit(RecordFileName:AnsiString; TimeType,Comp1,Comp2,Comp3:Cardinal; 
 WinHandle, NeededMem:longint; callback:TCallback):boolean; external 
'ISDoneInit@files:ISDone.dll stdcall';
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<=1000 then ISDoneProgressBar1.Position := OveralPct;
  LabelPct1.Caption := IntToStr(OveralPct div 10)+'.'+chr(48 + OveralPct mod 10)+'%';

//  LabelCurrFileName.Caption:='Instalando arquivos.. '+MinimizePathName(CurrentFile, 
LabelCurrFileName.Font, LabelCurrFileName.Width-ScaleX(100));

LabelCurrFileName.Caption:=ExpandConstant('')+MinimizePathName(ExpandConstant('{app}\ 
')+CurrentFile, LabelCurrFileName.Font,WizardForm.FilenameLabel.Width);
  LabelTime1.Caption:=ExpandConstant('{cm:ElapsedTime} ')+TimeStr2;
  LabelTime2.Caption:=ExpandConstant('{cm:RemainingTime} ')+TimeStr1;
//  LabelTime3.Caption:=ExpandConstant('{cm:AllElapsedTime}')+TimeStr3;
  Result := ISDoneCancel;
end;

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

procedure HideControls;
begin
  WizardForm.FileNamelabel.Hide;
  ISDoneProgressBar1.Hide;
  LabelPct1.Hide;
  LabelCurrFileName.Hide;
  LabelTime1.Hide;
  LabelTime2.Hide;
  MyCancelButton.Hide;
end;

procedure CreateControls;
var PBTop:integer;
begin
  PBTop:=ScaleY(165); //165
  ISDoneProgressBar1 := TNewProgressBar.Create(WizardForm);
  with ISDoneProgressBar1 do begin
    Parent   := WizardForm;                  //:= WizardForm.InstallingPage;
    Height   := ScaleY(20);                 //WizardForm.ProgressGauge.Height;
    Left     := ScaleX(65);
    Top      := PBTop;
    Width    := ScaleX(470);
    Max      := 1000;
  end;
  LabelPct1 := TLabel.Create(WizardForm);
  with LabelPct1 do begin
    Parent    := WizardForm;
    AutoSize  := true;
    Font.Height:=-25;
    Left      := ISDoneProgressBar1.Left -30 + ISDoneProgressBar1.Width div 2;
    Top       := ISDoneProgressBar1.Top + ScaleY(80);
    Width     := ScaleX(80);
  end;
  LabelCurrFileName := TLabel.Create(WizardForm);
  with LabelCurrFileName do begin
    Parent   := WizardForm;
    AutoSize := False;
    Width    := ISDoneProgressBar1.Width+ScaleX(30);
    Left     := ScaleX(65);
    Top      := ScaleY(140);
    Height   :=ScaleY(25);
//    Font.Color:= clWhite;
    Font.Size:= 10;
  end;
  LabelTime1 := TLabel.Create(WizardForm);
  with LabelTime1 do begin
    Parent   := WizardForm;
    AutoSize := False;
    Width    := ISDoneProgressBar1.Width div 2;
    Left     := ScaleX(65);
    Top      := PBTop + ScaleY(30);
    Height   :=ScaleY(25);
    Font.Size:= 8;
  end;
  LabelTime2 := TLabel.Create(WizardForm);
  with LabelTime2 do begin
    Parent   := WizardForm;
    AutoSize := False;
    Width    := ScaleX(200);
    Left     := Scalex (360); //Original 335 fonte 10
    Top      := LabelTime1.Top;
    Height   :=ScaleY(25);
    Font.Size:= 8;
  end;
//  LabelTime3 := TLabel.Create(WizardForm);
//  with LabelTime3 do begin
//    Parent   := WizardForm;  //FinishedPage para aparecer na ultima pagina 
//    AutoSize := False;
//    Font.Color:= clWhite; //Black
//    Width    := 250;
//    Left     := 10;
//    Top      := 330;
//    Height   :=ScaleY(25);
//    Font.Size:= 8;
//  end;
  MyCancelButton:=TButton.Create(WizardForm);
  with MyCancelButton do begin
    Parent := WizardForm;
    Top := ScaleY(360);
    Left := ScaleX(410);
    Width := ScaleX(90);
    Height := ScaleY(25);
    Caption := 'Cancelar';
    Top:=WizardForm.cancelbutton.top;
    OnClick:=@CancelButtonOnClick;
  end;
end;
////////////////////////////////////CONTADOR/COUNTER/////////////////////////
function GetTickCount: DWORD; external 'GetTickCount@kernel32.dll stdcall';

var
  StartTick: DWORD;
  PercentLabel: TNewStaticText;
  ElapsedLabel: TNewStaticText;
  RemainingLabel: TNewStaticText;

function TicksToStr(Value: DWORD): string;
var
  I: DWORD;
  Hours, Minutes, Seconds: Integer;
begin
  I := Value div 1000;
  Seconds := I mod 60;
  I := I div 60;
  Minutes := I mod 60;
  I := I div 60;
  Hours := I mod 24;
  Result := Format('%.2d:%.2d:%.2d', [Hours, Minutes, Seconds]);
end;

procedure InitializeWizard4();
begin
  PercentLabel := TNewStaticText.Create(WizardForm);
  PercentLabel.Parent    := WizardForm;
  PercentLabel.AutoSize  := true;
  PercentLabel.Font.Height:=-25; //SetBounds(245,220,150,20)
  PercentLabel.Left := ScaleX(245); //esquerda
  PercentLabel.Top := ScaleY(220);  //altura de cima para baixo
  PercentLabel.Width := ScaleX(150);  //comprimento
  PercentLabel.Height := ScaleY(20);  //tamanho

  ElapsedLabel := TNewStaticText.Create(WizardForm);
  ElapsedLabel.Parent   := WizardForm;
  ElapsedLabel.AutoSize := False;
  ElapsedLabel.Font.Size:= 8;  //SetBounds(65,190,150,20)
  ElapsedLabel.Left := ScaleX(65);
  ElapsedLabel.Top := ScaleY(190);
  ElapsedLabel.Width := ScaleX(150);
  ElapsedLabel.Height := ScaleY(20);

  RemainingLabel := TNewStaticText.Create(WizardForm);
  RemainingLabel.Parent   := WizardForm;
  RemainingLabel.AutoSize := False;
  RemainingLabel.Font.Size:= 8; // SetBounds(410,190,150,20)
  RemainingLabel.Left := ScaleX(410);
  RemainingLabel.Top := ScaleY(190);
  RemainingLabel.Width := ScaleX(150);
  RemainingLabel.Height := ScaleY(20);
end;
procedure CurPageChanged5(CurPageID: Integer);
begin
    PercentLabel.Visible := CurPageID = wpInstalling;
    ElapsedLabel.Visible := CurPageID = wpInstalling;
    RemainingLabel.Visible := CurPageID = wpInstalling;
    StartTick := GetTickCount;
end;

procedure CancelButtonClick(CurPageID: Integer; var Cancel, Confirm: Boolean);
begin
  if CurPageID= wpInstalling then
  begin
    Cancel := False;
    if ExitSetupMsgBox then
    begin
      Cancel := True;
      Confirm := False;
      PercentLabel.Visible := False;
      ElapsedLabel.Visible := False;
      RemainingLabel.Visible := False;
    end;
  end;
end;

procedure CurInstallProgressChanged(CurProgress, MaxProgress: Integer);
var
  CurTick: DWORD;
begin
  CurTick := GetTickCount;
  PercentLabel.Caption :=
    Format('%.2f %%', [(CurProgress * 100.0) / MaxProgress]);
  ElapsedLabel.Caption :=
    Format('Decorido: %s', [TicksToStr(CurTick - StartTick)]);
  if CurProgress > 0 then
  begin
    RemainingLabel.Caption :=
    Format('Restante: %s', [TicksToStr(
     ((CurTick - StartTick) / CurProgress) * (MaxProgress - CurProgress))]);
  end;
end;

0 个答案:

没有答案