0 is default, you change to 1,2 or 3 for you game directory.
Code:
#define NeedSize "500000"
#define NeedMem 512
;#define facompress
;#define SrepInside
;#define MSCInside
;#define XDelta
;#define PackZIP
#DEFINE Data1 'data1.arc'
#DEFINE Dir '2'
[Setup]
AppName=ISDone
AppVerName=ISDone
#ifdef Dir
#if Dir == "0"
DefaultDirName={pf}\ISDone
#else
#if Dir == "1"
DefaultDirName={pf32}\ISDone
#else
#if Dir == "2"
DefaultDirName={pf64}\ISDone
#else
#if Dir == "3"
DefaultDirName={sd}\ISDone
#endif
#endif
#endif
#endif
#endif
DefaultGroupName=ISDone Example
AllowNoIcons=yes
OutputDir=.
OutputBaseFilename=Setup
VersionInfoCopyright=ProFrager
#ifdef NeedSize
ExtraDiskSpaceRequired={#NeedSize}
#endif
[Icons]
Name: {commondesktop}\Disinstalla ISDone; Filename: {app}\unins000.exe; WorkingDir: {app}; Check: CheckError
[Files]
Source: Include\arc.ini; DestDir: {tmp}; Flags: dontcopy
Source: Include\English.ini; DestDir: {tmp}; Flags: dontcopy
Source: Include\unarc.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\InnoCallback.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\ISDone.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\Italian.ini; DestDir: {tmp}; Flags: dontcopy
#ifdef SrepInside
Source: Include\CLS-srep.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef MSCInside
Source: Include\CLS-MSC.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef facompress
Source: Include\facompress.dll; DestDir: {tmp}; Flags: dontcopy
Source: Include\facompress_MT.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef XDelta
Source: Include\XDelta3.dll; DestDir: {tmp}; Flags: dontcopy
#endif
#ifdef PackZIP
Source: Include\7z.dll; DestDir: {tmp}; Flags: dontcopy
#endif
[CustomMessages]
ITA.ExtractedFile=Processo:
ITA.Extracted=Estrazione dei Files...
ITA.CancelButton=Cancella
ITA.Error=ERRORE!
ITA.ElapsedTime=Trascorso
ITA.RemainingTime=Rimanente
ITA.EstimatedTime=Stimato
ITA.AllElapsedTime=Totale Impiegato
ITA.hour=ora
ITA.hours=ore
ITA.minute=minuto
ITA.minutes=minuti
ITA.second=secondo
ITA.seconds=secondi
[Languages]
Name: ITA; MessagesFile: compiler:Languages\Italian.isl
[UninstallDelete]
Type: filesandordirs; Name: {app}
[Code ]
procedure InitializeWizard();
begin
WizardForm.FilenameLabel.Visible:=False;
end;
const
PCFonFLY=true;
notPCFonFLY=false;
var
ProgrssLbl,CurrentFileNameLbl,Time1Lbl,Time2Lbl,Time3Lbl: TLabel;
ISDoneProgressBar: TNewProgressBar;
MyCancelButton: TButton;
TimeIncrease,ISDoneError:boolean;
OveralPct,ISDoneCancel,CProgress,Time, Time2, minutes, hours, seconds :integer;
TimerID: LongWord;
type
TCallback = function (OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;
TTimerProc = procedure();
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 WrapTimerProc(callback:TTimerProc; Paramcount:Integer): longword;
external 'wrapcallback@{tmp}\innocallback.dll stdcall delayload';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): LongWord;
external '[email protected] stdcall';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord;
external '[email protected] stdcall';
function TimeTextFormater(clock:String):String;
begin
case clock of
'hours': begin
if hours = 1 then
Result := CustomMessage('hour')
else
Result := CustomMessage('hours');
end;
'minutes': begin
if minutes = 1 then
Result := CustomMessage('minute')
else
Result := CustomMessage('minutes');
end;
'seconds': begin
if seconds = 1 then
Result := CustomMessage('second')
else
Result := CustomMessage('seconds');
end;
end;
end;
function TimeFormater(secondp:Integer):String;
begin
seconds := secondp
minutes := 0
hours := 0
if seconds >= 60 then begin
minutes := seconds / 60
seconds := seconds mod 60
end;
if minutes >= 60 then begin
hours := minutes / 60
minutes := minutes mod 60
end;
if hours <> 0 then
Result := IntToStr(hours) + ' ' + TimeTextFormater('hours') + ' ' + IntToStr(minutes) + ' ' + TimeTextFormater('minutes')
else begin
if minutes <> 0 then
Result := IntToStr(minutes) + ' ' + TimeTextFormater('minutes') + ' ' + IntToStr(seconds) + ' ' + TimeTextFormater('seconds')
else
Result := IntToStr(seconds) + ' ' + TimeTextFormater('seconds')
end;
end;
procedure Progress;
begin
with ISDoneProgressBar do begin
CProgress := (Position *1000) / Max;
if TimeIncrease then TimeIncrease := False else TimeIncrease := True;
if TimeIncrease then begin
Time := Time + 1;
if CProgress <> 0 then
Time2 := ((Time * 1000) / CProgress) - Time;
Time1Lbl.Caption := CustomMessage('ElapsedTime') + ': ' + TimeFormater(Time);
Time2Lbl.Caption := CustomMessage('RemainingTime') + ': ' + TimeFormater(Time2);
Time3Lbl.Caption := CustomMessage('AllElapsedTime') + ': ' + TimeFormater(Time2+Time);
if Copy(IntToStr(CProgress),0,Length(IntToStr(CProgress)) -1 ) = '' then
ProgrssLbl.Caption := '0.' + Copy(IntToStr(CProgress),Length(IntToStr(CProgress)), 1 ) + ' %'
else
ProgrssLbl.Caption := Copy(IntToStr(CProgress),0,Length(IntToStr(CProgress)) -1 ) + '.' + Copy(IntToStr(CProgress),Length(IntToStr(CProgress)), 1 ) + ' %';
end;
end;
end;
function ProgressCallback(OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:PAnsiChar): longword;
begin
if OveralPct<=1000 then ISDoneProgressBar.Position := OveralPct;
CurrentFileNameLbl.Caption:=ExpandConstant('{cm:ExtractedFile} ')+MinimizePathName(CurrentFile, CurrentFileNameLbl.Font, CurrentFileNameLbl.Width-ScaleX(100));
Result := ISDoneCancel;
end;
procedure CancelButtonOnClick(Sender: TObject);
begin
SuspendProc;
ISDoneProgressBar.State:=npbsPaused;
if MsgBox(SetupMessage(msgExitSetupMessage), mbConfirmation, MB_YESNO) = IDYES then ISDoneCancel:=1;
ISDoneProgressBar.State:=npbsNormal;
ResumeProc;
end;
procedure HideControls;
begin
WizardForm.FileNamelabel.Hide;
ISDoneProgressBar.Hide;
ProgrssLbl.Hide;
CurrentFileNameLbl.Hide;
Time1Lbl.Hide;
Time2Lbl.Hide;
MyCancelButton.Hide;
end;
procedure CenterText(txt: TControl);
begin
if Assigned(txt) and Assigned(txt.Parent) then
begin
txt.Left := (txt.Parent.Width - txt.Width) div 2;
end;
end;
procedure CreateControls;
begin
ISDoneProgressBar := TNewProgressBar.Create(WizardForm);
with ISDoneProgressBar do begin
Parent := WizardForm.InstallingPage;
Height := WizardForm.ProgressGauge.Height;
Left := WizardForm.ProgressGauge.Left;
Top := WizardForm.ProgressGauge.Top;
Width := WizardForm.ProgressGauge.Width;
Max := 1000;
end;
ProgrssLbl := TLabel.Create(WizardForm);
with ProgrssLbl do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Height := 25;
Left := 0;
Top := ISDoneProgressBar.Top+30;
Width := ScaleX(120);
Font.Style :=[fsBold];
Font.Height :=-22;
CenterText(ProgrssLbl);
end;
CurrentFileNameLbl := TLabel.Create(WizardForm);
with CurrentFileNameLbl do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Width := ISDoneProgressBar.Width+ScaleX(30);
Left := ScaleX(0);
Top := ScaleY(27);
end;
Time1Lbl := TLabel.Create(WizardForm);
with Time1Lbl do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Width := ISDoneProgressBar.Width div 2;
Left := ScaleX(0);
Top := ScaleY(115);
end;
Time2Lbl := TLabel.Create(WizardForm);
with Time2Lbl do begin
Parent := WizardForm.InstallingPage;
AutoSize := False;
Width := Time1Lbl.Width+ScaleX(40);
Left := 0;
Top := Time1Lbl.Top+20;
end;
Time3Lbl := TLabel.Create(WizardForm);
with Time3Lbl do begin
Parent := WizardForm.FinishedPage;
AutoSize := False;
Width := 300;
Left := 180;
Top := 200;
end;
MyCancelButton:=TButton.Create(WizardForm);
with MyCancelButton do begin
Parent:=WizardForm;
Width:=ScaleX(135);
Caption:=ExpandConstant('{cm:CancelButton}');
Left:=ScaleX(360);
Top:=WizardForm.CancelButton.Top
OnClick:=@CancelButtonOnClick;
end;
end;
Procedure CurPageChanged(CurPageID: Integer);
Begin
if (CurPageID = wpInstalling) then begin
TimerID := SetTimer(0, 0, 500 , WrapTimerProc(@Progress,0));
end;
if (CurPageID = wpFinished) then begin
KillTimer(0, TimerID);
end;
if (CurPageID = wpFinished) and ISDoneError then
begin
WizardForm.Caption:= ExpandConstant('{cm:Error}');
WizardForm.FinishedLabel.Font.Color:= clRed;
WizardForm.FinishedLabel.Caption:= SetupMessage(msgSetupAborted) ;
end;
end;
function CheckError:boolean;
begin
result:= not ISDoneError;
end;
procedure ExtractTempFile;
begin
ExtractTemporaryFile('InnoCallBack.dll');
ExtractTemporaryFile('arc.ini');
ExtractTemporaryFile('English.ini');
ExtractTemporaryFile('Italian.ini');
ExtractTemporaryFile('unarc.dll');
#ifdef SrepInside
ExtractTemporaryFile('CLS-srep.dll');
#endif
#ifdef MSCInside
ExtractTemporaryFile('CLS-MSC.dll');
#endif
#ifdef facompress
ExtractTemporaryFile('facompress.dll');
ExtractTemporaryFile('facompress_MT.dll');
#endif
#ifdef XDelta
ExtractTemporaryFile('XDelta3.dll');
#endif
#ifdef PackZIP
ExtractTemporaryFile('7z.dll');
#endif
end;
procedure CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then begin
//WizardForm.ProgressGauge.Hide;
WizardForm.CancelButton.Hide;
CreateControls;
WizardForm.StatusLabel.Caption:=ExpandConstant('{cm:Extracted}');
ISDoneCancel:=0;
ISDoneError:=true;
if ISDoneInit(ExpandConstant('{src}'), $F777, 0,0,0, MainForm.Handle, {#NeedMem}, @ProgressCallback) then begin
repeat
ChangeLanguage('Italian');
if not SrepInit('',512,0) then break;
if not ISArcExtract ( 0, 100, ExpandConstant('{src}\{#Data1}'), ExpandConstant('{app}\'), '', false, '', ExpandConstant('{tmp}\arc.ini'), ExpandConstant('{app}\'), notPCFonFLY{PCFonFLY}) then break;
ISDoneError:=false;
until true;
ISDoneStop;
end;
HideControls;
WizardForm.CancelButton.Visible:=true;
WizardForm.CancelButton.Enabled:=false;
end;
if (CurStep=ssPostInstall) and ISDoneError then begin
Time3Lbl.Visible:=False;
WizardForm.ProgressGauge.Width:=417;
WizardForm.ProgressGauge.State:=npbsError;
WizardForm.StatusLabel.Caption:=SetupMessage(msgStatusRollback);
Exec2(ExpandConstant('{uninstallexe}'), '/VERYSILENT', false);
end;
end;
function InitializeSetup: Boolean;
begin
ExtractTempFile;
Result:=True;
end;
procedure DeinitializeSetup;
begin
KillTimer(0,TimerID);
end;