[UninstallDelete] Type: filesandordirs; Name: {app} [Code] var LabelPct, Label2Pct, LabelCurrFileName, LabelStatusRollback, LabelStatus, LabelTime1, LabelTime2, LabelTime3: TLabel; CancelUnpackingBtn: HWND; OveralPct,Cancel, n, w:integer; CallBack:longword; MyError:boolean; pr:Extended; msgError: string; PBBkg1Img, PB1Img, PB2Img: Longint; PCFVer: double; type TCallback = function (OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:AnsiString): longword; TMessage = record hWnd: HWND; msg, wParam: Word; lParam: LongWord; Time: TFileTime; pt: TPoint; end; function WrapMyCallback(callback:TCallback; paramcount:integer):longword;external 'wrapcallback@files:innocallback.dll stdcall'; function PeekMessage(var lpMsg: TMessage; hWnd: HWND; wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): BOOL; external 'PeekMessageA@user32.dll stdcall'; function TranslateMessage(const lpMsg: TMessage): BOOL; external 'TranslateMessage@user32.dll stdcall'; function DispatchMessage(const lpMsg: TMessage): Longint; external 'DispatchMessageA@user32.dll stdcall'; function ISArcExtract(CurComponent:longword; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password, CfgFile, WorkPath: AnsiString; ExtractPCF: BOOL ):BOOL; external 'ISArcExtract@files:ISDone.dll stdcall'; function IS7ZipExtract(CurComponent:longword; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password: AnsiString):BOOL; external 'IS7zipExtract@files:ISDone.dll stdcall'; function ISRarExtract(CurComponent:longword; PctOfTotal:double; InName, OutPath: AnsiString; DeleteInFile:boolean; Password: AnsiString):BOOL; external 'ISRarExtract@files:ISDone.dll stdcall'; function ISPrecompExtract(CurComponent:longword; PctOfTotal:double; InName, OutFile: AnsiString; DeleteInFile:boolean):BOOL; external 'ISPrecompExtract@files:ISDone.dll stdcall'; function ISSRepExtract(CurComponent:longword; PctOfTotal:double; InName, OutFile: AnsiString; DeleteInFile:boolean):BOOL; external 'ISSrepExtract@files:ISDone.dll stdcall'; function ShowChangeDiskWindow(Text, DefaultPath, SearchFile:AnsiString):BOOL; external 'ShowChangeDiskWindow@files:ISDone.dll stdcall'; function ISDoneInitialize(RecordFileName:AnsiString; TimeType,AllComponents:longword; PrecompVers: double; RecursiveSubDir:boolean; WinHandle, NeededMem:longint; callback:longword):BOOL; external 'ISDoneInitialize@files:ISDone.dll stdcall'; function ISDoneStop:BOOL; external 'ISDoneStop@files:ISDone.dll stdcall'; function GetWindowLong(hWnd, nIndex: Integer): Longint; external 'GetWindowLongA@user32 stdcall delayload'; function SetWindowText(hWnd: Longint; lpString: AnsiString): Longint; external 'SetWindowTextA@user32 stdcall delayload'; function cm(Message: String): String; Begin Result:= ExpandConstant('{cm:'+ Message +'}') End; Procedure SetTaskBarTitle(Title: AnsiString); var h: Integer; begin h:= GetWindowLong(MainForm.Handle, -8); if h <> 0 then SetWindowText(h, Title); end; procedure AppProcessMessage; var Msg: TMessage; begin while PeekMessage(Msg, 0, 0, 0, 1) do begin TranslateMessage(Msg); DispatchMessage(Msg); end; end; function ProgressCallback(OveralPct,CurrentPct: integer;CurrentFile,TimeStr1,TimeStr2,TimeStr3:AnsiString): longword; begin w:=Round(360*OveralPct/1000); ImgSetPosition(PBImg,43,132,w,16); ImgSetVisiblePart(PBImg,0,0,w,16); LabelCurrFileName.Caption:=MinimizePathName(ExpandConstant('{app}\')+CurrentFile, LabelCurrFileName.Font, 360); LabelPct.Caption := IntToStr(OveralPct div 10)+'.'+chr(48 + OveralPct mod 10)+'%'; #ifdef SecondProgressBar w:=Round(360*CurrentPct/1000); ImgSetPosition(PB2Img,43,172,w,16); ImgSetVisiblePart(PB2Img,0,0,w,16); Label2Pct.Caption := IntToStr(CurrentPct div 10)+'.'+chr(48 + CurrentPct mod 10)+'%'; #endif ImgApplyChanges(WizardForm.Handle); AppProcessMessage; LabelTime1.Caption:=ExpandConstant('{cm:ElapsedTime} ')+TimeStr2; LabelTime2.Caption:=ExpandConstant('{cm:RemainingTime} ')+TimeStr1; LabelTime3.Caption:=ExpandConstant('{cm:AllElapsedTime}')+TimeStr3; Result := Cancel; end; procedure CancelUnpackingOnEnter(hBtn:HWND); begin sndPlaySound(ExpandConstant('{tmp}\WFEnter.wav'),$0001); end; procedure CancelUnpackingOnClick(hBtn:HWND); begin sndPlaySound(ExpandConstant('{tmp}\Click.wav'),$0001); if MsgBox( SetupMessage( msgExitSetupMessage ), mbConfirmation, MB_YESNO ) = IDYES then Cancel:= 1; end; procedure CreateISDoneComponents; begin LabelPct := TLabel.Create(WizardForm); with LabelPct do begin AutoSize:=False; SetBounds(ScaleX(420), ScaleY(132), ScaleX(638), ScaleY(17)); Transparent:=True; Font.Name:= 'Georgia' Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsItalic]; Parent := WizardForm; end; #ifdef SecondProgressBar Label2Pct := TLabel.Create(WizardForm); with Label2Pct do begin AutoSize:=False; SetBounds(ScaleX(420), ScaleY(172), ScaleX(638), ScaleY(17)); Transparent:=True; Font.Name:= 'Georgia' Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsItalic]; Parent := WizardForm; end; #endif LabelCurrFileName := TLabel.Create(WizardForm); with LabelCurrFileName do begin AutoSize:=False; SetBounds(ScaleX(41), ScaleY(105), ScaleX(638), ScaleY(17)); Transparent:=True; Font.Name:= 'Georgia' Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsItalic]; Caption:= ''; Parent := WizardForm; Hide; end; LabelStatusRollback := TLabel.Create(WizardForm); with LabelStatusRollback do begin Parent := WizardForm; AutoSize := False; SetBounds(ScaleX(41), ScaleY(80), ScaleX(400), ScaleY(17)); Transparent:=True; Font.Name:= 'Georgia'; Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsBold,fsItalic]; Caption := cm('ArcTitleBack'); end; LabelStatus := TLabel.Create(WizardForm); with LabelStatus do begin Parent := WizardForm; AutoSize := False; SetBounds(ScaleX(41), ScaleY(80), ScaleX(400), ScaleY(17)); Transparent:=True; Font.Name:= 'Georgia'; Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsBold,fsItalic]; Caption := cm('ArcTitle'); end; LabelTime1 := TLabel.Create(WizardForm); with LabelTime1 do begin Parent := WizardForm; Transparent:=True; AutoSize := False; Alignment:= taCenter; Font.Name:= 'Georgia'; Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsItalic]; Width := 300; Height := 50; Left := 100; #ifdef SecondProgressBar Top := 200; #else Top := 165; #endif end; LabelTime2 := TLabel.Create(WizardForm); with LabelTime2 do begin Parent := WizardForm; Transparent:=True; AutoSize := False; Alignment:= taCenter; Font.Name:= 'Georgia'; Font.Size:= 8; Font.Color:=$FFFFFF; Font.Style:=[fsItalic]; Width := 300; Height := 50; Left := 100; Top := LabelTime1.Top+20; end; LabelTime3 := TLabel.Create(WizardForm); with LabelTime3 do begin Parent := WizardForm; Transparent:=True; AutoSize := False; Alignment:= taCenter; Font.Name:= 'Georgia'; Font.Size:= 10; Font.Color:=$FFFFFF; Font.Style:=[fsBold, fsItalic]; Width := 300; Height := 50; Left := 100; Top := 250; end; CancelUnpackingBtn:=BtnCreate(WizardForm.Handle,408,297,80,80,ExpandConstant('{tmp}\button.png'),10,False); BtnSetEvent(CancelUnpackingBtn,BtnMouseEnterEventID,WrapBtnCallback(@CancelUnpackingOnEnter,1)); BtnSetEvent(CancelUnpackingBtn,BtnClickEventID,WrapBtnCallback(@CancelUnpackingOnClick,1)); BtnSetFont(CancelUnpackingBtn,WFButtonFont.Handle); BtnSetFontColor(CancelUnpackingBtn,$ffffff,$000000,$ffffff,$B6B6B6); BtnSetCursor(CancelUnpackingBtn,GetSysCursorHandle(32649)); BtnSetVisibility(CancelUnpackingBtn, False); end; Procedure UnpackingISDoneFinished(CurPageID: Integer); begin if (CurPageID = wpFinished) and MyError then begin WizardForm.Caption:= ExpandConstant('{cm:ISDoneError}'); SetTaskBarTitle(SetupMessage(msgErrorTitle)); FinishedHeadingLabel.Caption:=cm('ArcFinishedHeading'); FinishedHeadingLabel.Font.Color:= $0000C0; // red (красный) FinishedLabel.Caption:= msgError + ExpandConstant(' {cm:ArcTrouble}') + #10#13#10#13+ExpandConstant('{cm:FinishedLabel2}'); FinishedLabel.Font.Color:= $0000C0; // red (красный) LabelTime3.Hide; end; end; procedure UnpackingISDone(CurStep: TSetupStep); var ChComp, TmpValue: longword; tmp:integer; begin if CurStep = ssInstall then begin PBBkgImg:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\ProgressBackground.png'),41,130,365,20,True,True); PBImg:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\ProgressImg.png'),42,132,0,16,True,True); PB1Img:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\ProgressImg.png'),42,132,0,16,True,True); #ifdef SecondProgressBar PBBkg1Img:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\ProgressBackground.png'),41,170,365,20,True,True); PB2Img:=ImgLoad(WizardForm.Handle,ExpandConstant('{tmp}\ProgressImg.png'),42,172,0,16,True,True); #endif PBOldProc:=SetWindowLong(WizardForm.ProgressGauge.Handle,-4,WndProcCallBack(@PBProc,4)); LabelStatus.Show; BtnSetText(CancelUnpackingBtn,WizardForm.CancelButton.Caption); BtnSetVisibility(CancelUnpackingBtn, True); BtnSetVisibility(hCancelBtn, False); LabelPct.Show; LabelCurrFileName.Show; CallBack:=WrapMyCallback(@ProgressCallback,6); Cancel:=0; // Распаковка всех необходимых файлов в папку {tmp}. ExtractTemporaryFile('facompress.dll'); //ускоряет распаковку .arc архивов. // ExtractTemporaryFile('arc.ini'); // ExtractTemporaryFile('srep.exe'); #ifdef records ExtractTemporaryFile('records.inf'); #endif #ifdef precomp04 ExtractTemporaryFile('packjpg_dll.dll'); ExtractTemporaryFile('RTconsole.exe'); ExtractTemporaryFile('precomp04.exe'); #endif #ifdef precomp038 ExtractTemporaryFile('packjpg_dll.dll'); ExtractTemporaryFile('RTconsole.exe'); ExtractTemporaryFile('precomp038.exe'); ExtractTemporaryFile('zlib1.dll'); #endif #ifdef unrar ExtractTemporaryFile('Unrar.dll'); #endif // Подготавливаем переменную, содержащую всю информацию о выделенных компонентах для ISDone.dll ChComp:=0; #ifdef Components TmpValue:=1; if IsComponentSelected('text\rus') then ChComp:=ChComp+TmpValue; //компонент 1 TmpValue:=TmpValue*2; if IsComponentSelected('text\eng') then ChComp:=ChComp+TmpValue; //компонент 2 TmpValue:=TmpValue*2; if IsComponentSelected('voice\rus') then ChComp:=ChComp+TmpValue; //компонент 3 TmpValue:=TmpValue*2; if IsComponentSelected('voice\eng') then ChComp:=ChComp+TmpValue; //компонент 4 #endif #ifdef precomp04 PCFVer:=0.4; #else #ifdef precomp038 PCFVer:=0.38; #else PCFVer:=0; #endif #endif repeat MyError:=true; if not ISDoneInitialize(ExpandConstant('{src}\records.inf'), $1111, ChComp, PCFVer, false, MainForm.Handle, {#NeedMem}, CallBack) then break; repeat if not ISArcExtract ( 0, 0, ExpandConstant('{src}\bin\CallOfDutyBlackOps.bin'), ExpandConstant('{app}\'), false, '', '', '', false ) then break; //далее находятся закомментированые примеры различных комбинаций параметров функций распаковки if not ISSRepExtract ( 0, 0, ExpandConstant('{app}\CallOfDutyBlackOps.srp'),ExpandConstant('{app}\CallOfDutyBlackOps.pcf'), true ) then break; if not ISPrecompExtract( 0, 0, ExpandConstant('{app}\CallOfDutyBlackOps.pcf'), ExpandConstant('{app}\CallOfDutyBlackOps.7z'), true ) then break; if not IS7ZipExtract ( 0, 0, ExpandConstant('{app}\CallOfDutyBlackOps.7z'), ExpandConstant('{app}\'), true, '' ) then break; //if not IS7ZipExtract ( 0, 0, ExpandConstant('{src}\Data64.7z'), ExpandConstant('{app}'), false, '' ) then break; //if not ISArcExtract ( 0, 0, ExpandConstant('{app}\data64.arc'), ExpandConstant('{app}\'), true, '', '', '', false ) then break; (* if not ISArcExtract ( 0, 0, ExpandConstant('{src}\CODMW_2.arc'), ExpandConstant('{app}\data1'), false, '', '', '', false ) then break; if not ISSRepExtract ( 0, 0, ExpandConstant('{app}\data1\CODMW2.srep'), ExpandConstant('{app}\data1\CODMW2.pcf'), true ) then break; if not ISPrecompExtract( 0, 0, ExpandConstant('{app}\data1\CODMW2.pcf'), ExpandConstant('{app}\data1\CODMW2.7z'), true ) then break; if not IS7ZipExtract ( 0, 0, ExpandConstant('{app}\data1\CODMW2.7z'), ExpandConstant('{app}\data1'), true, '' ) then break; if not ShowChangeDiskWindow('Пожалуйста, вставьте диск 2 и дождитесь его инициализации.', ExpandConstant('{src}'),'CODMW2_Disk2.arc' ) then break; if not ISArcExtract ( 1, 0, ExpandConstant('{src}\rustext.arc'), ExpandConstant('{app}'), false, '', '', '', false ) then break; if not ISArcExtract ( 2, 0, ExpandConstant('{src}\engtext.arc'), ExpandConstant('{app}'), false, '', '', '', false ) then break; if not ISArcExtract ( 3, 0, ExpandConstant('{src}\rusvoice.arc'), ExpandConstant('{app}'), false, '', '', '', false ) then break; if not ISArcExtract ( 4, 0, ExpandConstant('{src}\engvoice.arc'), ExpandConstant('{app}'), false, '', '', '', false ) then break; if not ShowChangeDiskWindow('Пожалуйста, вставьте первый диск и дождитесь его инициализации.', ExpandConstant('{src}'),'CODMW_2.arc' ) then break; if not ISArcExtract ( 0, 0, ExpandConstant('{src}\sds_ru2.arc'), ExpandConstant('{app}\data1'), false, '', '', ExpandConstant('{app}\data1'), true) then break; if not ISArcExtract ( 0, 0, ExpandConstant('{src}\sds_ru.arc'), ExpandConstant('{app}\data1'), false, '', '', ExpandConstant('{app}\data1'), true) then break; if not ISPrecompExtract( 0, 0, ExpandConstant('{src}\data1\*.pcf'), ExpandConstant('{src}\data1'), false) then break; if not IS7ZipExtract ( 0, 0, ExpandConstant('{src}\data1\sds_ru.7z'), ExpandConstant('{src}\data1'), true, '') then break; if not ISRarExtract ( 0, 0, ExpandConstant('{src}\data_*.rar'), ExpandConstant('{app}'), false, '' ) then break; if not ISRarExtract ( 0, 0, ExpandConstant('{src}\*part1.rar'), ExpandConstant('{app}'), false, 'Password' ) then break; if not IS7ZipExtract ( 0, 0, ExpandConstant('{src}\data*.7z'), ExpandConstant('{app}\data1'), false, '' ) then break; if not IS7ZipExtract ( 0, 0, ExpandConstant('{src}\sound.7z'), ExpandConstant('{app}\data1'), false, '' ) then break; if not ISArcExtract ( 0, 33, ExpandConstant('{src}\dataR.arc'), ExpandConstant('{app}\data1'), false, '', '', '',false) then break; if not ISArcExtract ( 0, 33, ExpandConstant('{src}\CODMW_*.arc'), ExpandConstant('{app}\data1'), false, '', '', '',false) then break; if not ISArcExtract ( 0, 34, ExpandConstant('{src}\dataR.arc'), ExpandConstant('{app}\data1\'), false, '', '', '',false) then break; if not ISPrecompExtract( 0, 0, ExpandConstant('{src}\*.pcf'), ExpandConstant('{app}\data1'), false) then break; if not ISPrecompExtract( 0, 0, ExpandConstant('{src}\data0.pcf'), ExpandConstant('{app}\data1'), false) then break; if not ISSRepExtract ( 0, 0, ExpandConstant('{src}\*.srep'), ExpandConstant('{app}\data1\'), false) then break; if not ISSRepExtract ( 0, 0, ExpandConstant('{src}\data02.srep'), ExpandConstant('{app}\data1\data.pcf'), false) then break; *) MyError:=false; until true; ISDoneStop; until true; BtnSetVisibility(CancelUnpackingBtn, False); BtnSetVisibility(hCancelBtn, True); BtnSetEnabled(hCancelBtn, False); LabelStatus.Hide; LabelPct.Hide; LabelTime1.Hide; LabelTime2.Hide; LabelCurrFileName.Hide; end; if (CurStep=ssPostInstall) and MyError then begin Exec(ExpandConstant('{uninstallexe}'), '/SILENT','', sw_Hide, ewWaitUntilTerminated, tmp); end; end; |