View Single Post
  #11  
Old 26-10-2018, 03:07
Midnights Midnights is offline
Registered User
 
Join Date: Aug 2015
Location: Canada
Posts: 23
Thanks: 2
Thanked 0 Times in 0 Posts
Midnights is on a distinguished road
Hi, how i can add Time Remaining/Elapsed to the script?

Anyone can share me the part of the code i need?

Here is what i use (original script):

Code:
procedure ExtractTemporaryFileIfNoExist(Filename: String);
begin
  if not FileExists(ExpandConstant('{tmp}\' + Filename)) then
    ExtractTemporaryFile(Filename);
end;

procedure ISDone_Resources;
begin
  ExtractTemporaryFileIfNoExist('Arc.ini');
  ExtractTemporaryFileIfNoExist('English.ini');
  ExtractTemporaryFileIfNoExist('ISDone.dll');
  ExtractTemporaryFileIfNoExist('UnArc.dll');
  ExtractTemporaryFileIfNoExist('arc.ini');
  ExtractTemporaryFileIfNoExist('CLS-DiskSpan.dll');
  ExtractTemporaryFileIfNoExist('CLS-LOLZ.dll');
  ExtractTemporaryFileIfNoExist('CLS-LOLZ_x64.exe');
  ExtractTemporaryFileIfNoExist('CLS-LOLZ_x86.exe');
  ExtractTemporaryFileIfNoExist('CLS-SREP.DLL');
  ExtractTemporaryFileIfNoExist('CLS-SREP_x64.exe');
  ExtractTemporaryFileIfNoExist('CLS-SREP_x64.exe');
  ExtractTemporaryFileIfNoExist('XTool.exe');
  ExtractTemporaryFileIfNoExist('hif2raw_dll.dll');
  ExtractTemporaryFileIfNoExist('liblz4.dll');
  ExtractTemporaryFileIfNoExist('libzstd.dll');
  ExtractTemporaryFileIfNoExist('lzo2.dll');
  ExtractTemporaryFileIfNoExist('oo2core_4_win64.dll');
  ExtractTemporaryFileIfNoExist('raw2hif_dll.dll');
  ExtractTemporaryFileIfNoExist('zlibwapi.dll');
end;        
                                          
type
  TCallback = function (OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;
  TRequestDisk = function(APath, AFilename: String): String;

var
  ISDoneCancel: Integer;              
  ISDoneError: Boolean; 

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 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';
procedure ClsInit(Path: String; Parent: HWND);
  external 'ClsInit@files:cls-diskspan.dll cdecl'; 
procedure ClsSourcePath(Path: String);
  external 'ClsFunc1@files:cls-diskspan.dll cdecl'; // deprecated 'use ClsInit instead'
procedure ClsDiskRequest(RequestDisk: TRequestDisk);
  external 'ClsFunc2@files:cls-diskspan.dll cdecl'; // deprecated 'use ClsInit instead'

function GetMessage(MsgNum: Integer; Var1, Var2: String): String;                                                            
begin
  Result:=ExpandConstant('{cm:Message'+IntToStr(MsgNum)+'}');
  StringChange(Result,'%1',Var1);
  StringChange(Result,'%2',Var2);
end;

procedure ProgressLabels(Status, CurrentFile: String);
begin
  WizardForm.StatusLabel.Caption:=Status;
  with WizardForm.FilenameLabel do
    Caption := MinimizePathName(CurrentFile, Font, Width);
end;

function ProgressCallback(OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;
begin
  ProgressLabels(GetMessage(3,'',''), CurrentFile);
  if OveralPct <= WizardForm.ProgressGauge.Max then
    WizardForm.ProgressGauge.Position := OveralPct;
  Result := ISDoneCancel;                                                            
end;                                                                    
                                                                                                                                                       
function MyDiskRequest(APath, AFilename: String): String;                          
var                                                                                        
  MsgResult: Integer;                                                                                    
begin                                                                                                                                                 
  Result := APath;                                        
  if not FileExists(AddBackSlash(Result) + AFilename) then
    repeat
      MsgResult := MsgBox(GetMessage(1, AFilename,''), mbConfirmation, MB_OKCANCEL);
      if MsgResult = mrCancel then
        WizardForm.CancelButton.OnClick(nil);
      if (MsgResult = mrOk) and (FileExists(AddBackSlash(Result) + AFilename) = False) then
        if MsgBox(GetMessage(2,'',''), mbConfirmation, MB_YESNO) = mrYes then
          if GetOpenFileName('', Result, '', AFilename + '|' + AFilename, AFilename) then
            Result := ExtractFileDir(Result); 
    until (FileExists(AddBackSlash(Result) + AFilename) = True) or (ISDoneError = True);
end;
                                                                                                         
procedure ISDone_Unpack;                                                             
begin                                                                 
  ISDone_Resources;             
  ISDoneError:=false;
  if ISDoneInit(ExpandConstant('{tmp}\records.inf'), $F777, 0,0,0, MainForm.Handle, 512, @ProgressCallback) then
  begin
    ChangeLanguage('English');
    if SrepInit('',512,0) and PrecompInit('',128, 0) and FileSearchInit(true) then
    begin
      WizardForm.ProgressGauge.Position := 0;                                       
      Wizardform.ProgressGauge.Max := 1000;                                     
      ClsInit(ExpandConstant('{src}'),WizardForm.Handle);
      // ClsSourcePath(ExpandConstant('{src}'));
      // ClsDiskRequest(@MyDiskRequest); // buggy as fuck... use at own risk
      if not ISArcExtract(0, 100, ExpandConstant('{src}\data.bin.001'), ExpandConstant('{app}'), '', false, '', ExpandConstant('{tmp}\arc.ini'), ExpandConstant('{app}'), false) then
        ISDoneError := True;
    end;
    ISDoneStop;
  end;
  if ISDoneError = True then
    WizardForm.CancelButton.OnClick(nil);
end;

procedure CurStepChanged(CurStep: TSetupStep);
var
  MsgResult: Integer;
begin                                                                                  
  case CurStep of
    ssInstall:
      ISDone_Unpack;
    ssPostInstall:
    begin
      if ISDoneError then
        Exec(ExpandConstant('{uninstallexe}'),'/verysilent','',SW_HIDE, ewWaitUntilTerminated, MsgResult);
    end;
  end;
end;
Reply With Quote