Вопрос Глупые вопросы по Inno от EvilAlex =)

EvilAlex

Старожил
Доброго времени суток!
Как сделать так чтобы после установки, при закрытии сетапа, из папки темп удалялась папка с файлами установщика ? В данный момент у меня там создается 2 папки и только 1 удаляется после завершения. вторая в которой все длл и картинки остается.


Снимок.PNG
 

ffmla

Участник
Hello,
Did you try deleteafterinstall Flag.?
Код:
Source: InstallFiles\*; Flags: dontcopy deleteafterinstall
if still the error present,may be at the end of installation your setup crashed.
See your compiler output if it return exit code 2 while exit.
PS:I check your old script Script+RePack by EVIL ALEX. Its delete tmp file while canceling.
 

ffmla

Участник
Oops..! I found it.
In DeinitializeSetup some alteration needed.
Here the solution..!
Код:
procedure DeinitializeSetup;
begin
  //WFDeInit;
  RemoveFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0);
  RemoveFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
  SetWindowlong(WizardForm.Handle, GWL_WNDPROC, OldProc); //It should be before Wizardform.free command..!
  WizardForm.Free;
  gdipShutdown;
end;
PS. One more thing,you use the gdipShutdown two times. That is not necessary.
 
Последнее редактирование:

Shegorat

Lord of Madness
Администратор
@EvilAlex, неправильно происходит деинициализация сетапника
Код:
procedure DeinitializeSetup;
begin
  SetWindowlong(WizardForm.Handle, GWL_WNDPROC, OldProc); // Первым делом возвращаем старую оконную процедуру
  RemoveFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0); // Удаляем шрифты
  RemoveFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
  gdipShutdown; // Дублирует WFDeInit, выгружаем ботву
end;
 

SBalykov

Старожил
@EvilAlex, неправильно происходит деинициализация сетапника
Код:
procedure DeinitializeSetup;
begin
  SetWindowlong(WizardForm.Handle, GWL_WNDPROC, OldProc); // Первым делом возвращаем старую оконную процедуру
  RemoveFontResource(ExpandConstant('{tmp}\{#Font}'), FR_PRIVATE, 0); // Удаляем шрифты
  RemoveFontResource(ExpandConstant('{tmp}\{#Font2}'), FR_PRIVATE, 0);
  gdipShutdown; // Дублирует WFDeInit, выгружаем ботву
end;
Не совсем согласен.
Процедуру SetWindowlong(WizardForm.Handle, GWL_WNDPROC, OldProc);
следует выполнять до WizardForm.Free,
поэтому ее лучше перенести в ssPostInstall, либо в ssDone в зависимости от выполняемых в них действиях...
 

Shegorat

Lord of Madness
Администратор
@SBalykov, а зачем вызывать явно WizardForm.Free?
В стандартном алгоритме работы инсталлятора, в момент вызова DeinitializeSetup, WizardForm ещё не освобождена. Она освобождается после вызова этой процедуры.

В скрипте выше оконная процедура используется для добавления прозрачности к окну при перетаскивании. Переносить SetWindowLong на этап ssPostInstall или ssDone не нужно, т.к. до них пользователь может и не дойти, если закроет инсталлятор раньше завершения установки.
 

SBalykov

Старожил
@SBalykov, а зачем вызывать явно WizardForm.Free?
В стандартном алгоритме работы инсталлятора, в момент вызова DeinitializeSetup, WizardForm ещё не освобождена. Она освобождается после вызова этой процедуры.

В скрипте выше оконная процедура используется для добавления прозрачности к окну при перетаскивании. Переносить SetWindowLong на этап ssPostInstall или ssDone не нужно, т.к. до них пользователь может и не дойти, если закроет инсталлятор раньше завершения установки.
Я как раз это и имел ввиду.
Если пользователь дойдет до процедуры ssDone, то инсталлятор выдаст ошибку процедуры SetWindowLong, так как WizardForm.Free уже отработает...
 

Shegorat

Lord of Madness
Администратор
На каком этапе произойдет освобождение WizardForm?
Я писал об этом выше.
По умолчанию освобождение происходит после выполнения процедуры DeinitializeSetup. Которая вызывается всегда при завершении работы инсталлятора, если он не крашнулся.
А ssDone это лишь один из шагов установки, которые выполняются на InstallingPage
Код:
TSetupStep = (ssPreInstall, ssInstall, ssPostInstall, ssDone);
 

SBalykov

Старожил
Я писал об этом выше.
По умолчанию освобождение происходит после выполнения процедуры DeinitializeSetup. Которая вызывается всегда при завершении работы инсталлятора, если он не крашнулся.
А ssDone это лишь один из шагов установки, которые выполняются на InstallingPage
Код:
TSetupStep = (ssPreInstall, ssInstall, ssPostInstall, ssDone);
Согласен, но Вы сами ответили на вопрос, - если он не "крашнулся" или пользователь не отменил распаковку.
Поэтому в IsDone процедуру WizardForm.Free и выполняют в ssDone...
 

Shegorat

Lord of Madness
Администратор
Согласен, но Вы сами ответили на вопрос, - если он не "крашнулся" или пользователь не отменил распаковку.
Я не говорил про "отменил установку", только про краши, когда нормальное завершение приложения невозможно.

Поэтому в IsDone процедуру WizardForm.Free и выполняют в ssDone...
Я извиняюсь, в каком месте вы это видели?

Просто запустите этот код и попробуйте завершить установку, отменить, закрыть инсталлятор и т.д. И, я надеюсь, этого будет достаточно для понимания в чём отличие DeinitializeSetup от ssDone
Код:
[Setup]
AppName=Example
AppVerName=Example
DefaultDirName={pf}\Example

[code]
procedure DeinitializeSetup();
begin
  MsgBox('DeinitializeSetup', mbInformation, MB_OK);
end;


procedure CurStepChanged(CurStep: TSetupStep);
begin
  if (CurStep == ssDone)
    MsgBox('Installing ssDone', mbInformation, MB_OK);
end;
 

ffmla

Участник
@Shegorat
You removed the line WizardForm.Free in the script.is it really necessary?.
When did we use WizardForm.Free command? or what is the purpose of WizardForm.Free ?
 

Shegorat

Lord of Madness
Администратор
@SBalykov, уж не обижайтесь, но скрипты я начал писать ещё 10 лет назад. Да и в целом в программировании разбираюсь. И поэтому лучше знаю жизненный цикл Inno

@ffmla,
WizardForm.Free используется для явного освобождения ресурсов формы инсталлятора. Применять её нужно только в исключительных случаях и очень осторожно, иначе это чревато некорректным поведением приложения.
 

EvilAlex

Старожил
Чет я опять накосячил. если при выборе языка нажать отмену, то инсталлятор вылетает с ошибкой, в компиляторе ругается на
Код:
procedure WFDeInit;
begin
  gdipShutDown;
end;
Код:
#ifdef UNICODE
  #define A "W"
#else
  #define A "A"
#endif

#define Font "Play.ttf"
#define FontName "Play"
#define Font2 "Play-Bold.ttf"
#define FontName2 "Play Bold"

#define NeedInstallSize 2025
#define NeedMem 512

// '#39' = '  // '#45' = - // '#58' = :

#define AppName       "WG MU Online Season 16"
#define AppName2      "WG MU Online s16"
#define MyAppExe      "Launcher.exe"
#define MyAppIcon     "main.exe"

#define Password      ""            ;пароль на архив
#define MyInfoVer     "1.5"         ;Версия инсталлятора

#define ApRePack      "RePack by EvilAlex"
#define AppVer        "0.0.1"

[Setup]
AppName={#AppName2}
AppVersion={#AppVer}

VersionInfoDescription=Installer {#AppName2}
VersionInfoProductName=RePack {#AppName2}
VersionInfoVersion={#MyInfoVer}

AppCopyright={#ApRePack}
AppPublisher={#ApRePack}

DefaultDirName={pf}\{#AppName2}
DefaultGroupName={#AppName2}

UninstallFilesDir={app}
SetupIconFile=InstallFiles\inicon.ico
UninstallIconFile=InstallFiles\unicon.ico
UninstallDisplayIcon={app}\{#MyAppIcon}

RawDataResource=font:InstallFiles\{#Font} | font2:InstallFiles\{#Font2}

//InternalCompressLevel=ultra64
//Compression=lzma2/ultra64
//SolidCompression=true

Compression=lzma2/ultra64
InternalCompressLevel=ultra
CompressionThreads=2
SolidCompression=True

DiskSpanning=false
DiskSliceSize=2100000000
;DiskSliceSize=52000000

DisableReadyPage=true
DisableProgramGroupPage=true
ShowComponentSizes=false

[Languages]
Name: "english"; MessagesFile: "compiler:Languages\English.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"

#include "Modules\CustomMessages.iss"

[UninstallDelete]
Type: filesandordirs; Name: {app}

[Files]
Source: InstallFiles\*; DestDir: {tmp}; Flags: dontcopy noencryption
//#include "Modules\files.iss"
//Source: "ARIALUNI.TTF"; DestDir: "{fonts}"; FontInstall: "Arial Unicode MS"; Flags: onlyifdoesntexist uninsneveruninstall

[Icons]
Name: "{group}\{#AppName2}"; Filename: "{app}\{#MyAppExe}"; IconFilename: {app}\{#MyAppIcon}
Name: "{group}\{cm:delet} {#AppName2}"; Filename: {uninstallexe}
Name: "{userdesktop}\{#AppName2}"; Filename: "{app}\{#MyAppExe}"; IconFilename: {app}\{#MyAppIcon}
Name: "{userappdata}\RePack by EvilAlex\{#AppName2}"; Filename: "{app}\{#MyAppExe}"; IconFilename: {app}\{#MyAppIcon}

[Run]
Filename: {app}\Redist\dxwebsetup.exe; Parameters: /q; StatusMsg:{cm:Doppo1}; Flags: skipifdoesntexist; Check: DirectXCheck
Filename: {app}\Redist\VCRHyb64.exe; Parameters: /S; StatusMsg:{cm:Doppo2}; Flags: skipifdoesntexist; Check: VCRedistCheck
Filename: {app}\Redist\dotNetFx40.exe; Parameters: /q; StatusMsg:{cm:Doppo3}; Flags: skipifdoesntexist; Check: dotNetFx40Check


[*Code]
type
    TTimerProc = procedure(HandleW, Msg, idEvent, TimeSys: LongWord);

var
  WelcomeLabel,WelcomeLabel1,WelcomeLabel2,Dirlabel,Grouplabel,Iconslabel,Compslabel,Statuslabel: TLabel;
  Bevel2,BevelPanel1,BevelPanel2: TBevel;
  Panel1,Panel2,Panel3: TPanel;
  Desktop,StartMenu,QuickLaunch,DirectX,VCRedist,dotNetFx40: TCheckBox;
  bmpfile,BmpFile1:TBitmapImage;
  BigOk, BigFail, BigWarn, BigInst: Longint;
  Frame: TPanel;
  PercentsTimer: LongWord;
  PercentsLabel: TLabel;
  StartButton: TNewButton;
  MouseLabel,SiteLabel,MouseLabel2,SiteLabel2: TLabel;

#include "Modules\botva2.iss"
#include "Modules\TFont.iss"
#include "Modules\WinTB.iss"
#include "Modules\Uninstall.iss"
//#include "Modules\XML.iss"

function WrapTimerProc(callback: TTimerProc; Paramcount: Integer): longword; external 'wrapcallback@files:innocallback.dll stdcall';
function SetTimer(hWnd, nIDEvent, uElapse, lpTimerFunc: LongWord): longword; external 'SetTimer@user32';
function KillTimer(hWnd, nIDEvent: LongWord): LongWord; external 'KillTimer@user32 stdcall delayload';

Function NumToStr2(Float: Extended): String;
Begin
    Result:= Format('%.1n', [Float]); StringChange(Result, ',', '.');
    while ((Result[Length(Result)] = '0') or (Result[Length(Result)] = '.')) and (Pos('.', Result) > 0) do
        SetLength(Result, Length(Result)-1);
End;

Procedure PercentsProc(h, msg, idevent, dwTime: Longword);
Begin
  with WizardForm.ProgressGauge do
  begin
      PercentsLabel.Caption:=ExpandConstant('{cm:PercentsLabel}: ')+ NumToStr2((Position*100)/Max) + ' %';
  end;
End;

const
  A1='А';
  Z1='Я';
  A2='а';
  Z2='я';
  X1='ё';
  X2='Ё';

function NextButtonClick(CurPageID: Integer): Boolean;
var
  i: integer;
  c: char;
begin
   Result := True;
   if CurPageID = wpSelectDir then begin
      for i:=1 to length(WizardForm.DirEdit.text) do begin
         c:=WizardForm.DirEdit.text[i];
         if (c>=A1)and(c<=Z1) or (c>=A2)and(c<=Z2) or (c=X1) or (c=X2) then begin
            MsgBox( 'В пути установки присутствуют русские буквы, что недопустимо'#13#13'Пожалуйста, повторите ввод.', mbError, mb_Ok);
            Result := False ;
            exit;
         end;
      end;
   end;
end;

procedure StartButtonClick(Sender: TObject);
var
  ResultCode: Integer;
begin
    WizardForm.NextButton.OnClick(nil);
  begin
    ExecAsOriginalUser(ExpandConstant('{app}\{#MyAppExe}'), '', '',
    SW_SHOWNORMAL, ewNoWait, ResultCode);
  end;
end;

function InitializeSetup(): Boolean;
begin
  if not FileExists(ExpandConstant('{tmp}\b2p.dll')) then ExtractTemporaryFile('b2p.dll');
  if not FileExists(ExpandConstant('{tmp}\WinTB.dll')) then ExtractTemporaryFile('WinTB.dll');
  if not FileExists(ExpandConstant('{tmp}\botva2.dll')) then ExtractTemporaryFile('botva2.dll');
  if not FileExists(ExpandConstant('{tmp}\CallbackCtrl.dll')) then ExtractTemporaryFile('CallbackCtrl.dll');
  Result := True;
end;

procedure WizardFormInit;
begin
  ExtractTemporaryFile('no.bmp');
  ExtractTemporaryFile('ok.bmp');
  ExtractTemporaryFile('BG.png');
  ExtractTemporaryFile('BigOk.png');
  ExtractTemporaryFile('BigFail.png');
  ExtractTemporaryFile('BigWarn.png');
  ExtractTemporaryFile('BigInst.png');

  ExtractTemporaryFile('CallbackCtrl.dll');
  ExtractTemporaryFile('botva2.dll');


  with WizardForm do begin
    ClientWidth:=ScaleX(650);
    ClientHeight:=ScaleY(405);
    AutoScroll := False;
    Position := poScreenCenter;
    Color := $c8c8c8;
    InnerNotebook.Hide;
    OuterNotebook.Hide;
    Bevel.Hide;
    Caption := '{#AppName}';
    Application.Title := '{#AppName}';
  end;
  //
  Frame := TPanel.Create(WizardForm);
  with Frame do
  begin
    Parent := WizardForm;
    Left := ScaleX(0);
    Top := ScaleY(0);
    Width := ScaleX(660);
    Height := ScaleY(354);
    Color := 13948116;
    BevelOuter := bvNone;
  end;
  //////////////////////////////////////////////////////
  Bevel2 := TBevel.Create(WizardForm);
  with Bevel2 do
  begin
    Parent := WizardForm;
    Left := ScaleX(0);
    Top := WizardForm.Height-ScaleX(80);
    Width := WizardForm.ClientWidth;
    Height := ScaleY(2);
  end;

  ImgLoad(Frame.Handle,ExpandConstant('{tmp}\BG.png'),0,0,ScaleX(660),ScaleY(354),True,True);

  BigOk:=ImgLoad(Frame.Handle,ExpandConstant('{tmp}\BigOk.png'),ScaleX(301),ScaleY(50),ScaleX(58),ScaleY(58),True,True);
  BigFail:=ImgLoad(Frame.Handle,ExpandConstant('{tmp}\BigFail.png'),ScaleX(301),ScaleY(50),ScaleX(58),ScaleY(58),True,True);
  BigWarn:=ImgLoad(Frame.Handle,ExpandConstant('{tmp}\BigWarn.png'),ScaleX(301),ScaleY(50),ScaleX(58),ScaleY(58),True,True);
  BigInst:=ImgLoad(Frame.Handle,ExpandConstant('{tmp}\BigInst.png'),ScaleX(301),ScaleY(50),ScaleX(58),ScaleY(58),True,True);
end;

////////////////////////////////////
#include "Modules\NSize.iss"
////////////////////////////////////

function desktopicon: Boolean;
begin
  Result:=Desktop.Checked;
end;

function groupicon: Boolean;
begin
  Result:= StartMenu.Checked;
end;

procedure StartMenuOnClick(Sender: TObject);
begin
  WizardForm.GroupEdit.Enabled:= StartMenu.Checked;
  WizardForm.GroupBrowseButton.Enabled:= StartMenu.Checked;
end;

function quicklaunchicon: Boolean;
begin
  Result:=QuickLaunch.Checked;
end;
////////////////////////////////////
function DirectXCheck: Boolean;
begin
  WizardForm.StatusLabel.Top := ScaleY(40);
  WizardForm.StatusLabel.Left := ScaleX(40);
  WizardForm.StatusLabel.Width := ScaleX(250);
  WizardForm.StatusLabel.Height := ScaleX(200);
  WizardForm.StatusLabel.Caption:=ExpandConstant('{cm:Doppo1}');
  Result:=DirectX.Checked;
  WizardForm.ProgressGauge.Hide;
  PercentsLabel.Hide;
end;

function VCRedistCheck: Boolean;
begin
  WizardForm.StatusLabel.Top := ScaleY(40);
  WizardForm.StatusLabel.Left := ScaleX(40);
  WizardForm.StatusLabel.Width := ScaleX(250);
  WizardForm.StatusLabel.Height := ScaleX(200);
  WizardForm.StatusLabel.Caption:=ExpandConstant('{cm:Doppo2}');
  Result:=VCRedist.Checked;
  WizardForm.ProgressGauge.Hide;
  PercentsLabel.Hide;
end;

function dotNetFx40Check: Boolean;
begin
  WizardForm.StatusLabel.Top := ScaleY(40);
  WizardForm.StatusLabel.Left := ScaleX(40);
  WizardForm.StatusLabel.Width := ScaleX(250);
  WizardForm.StatusLabel.Height := ScaleX(200);
  WizardForm.StatusLabel.Caption:=ExpandConstant('{cm:Doppo3}');
  Result:=dotNetFx40.Checked;
  WizardForm.ProgressGauge.Hide;
  PercentsLabel.Hide;
end;

procedure RedesignWizardForm;
begin
  with WizardForm.CancelButton do
  begin
    Parent := WizardForm;
    Left := ScaleX(500);
    Top := ScaleY(366);
    Width:= ScaleX(75);
    Height:= ScaleY(25);
  end;

  with WizardForm.NextButton do
  begin
    Parent := WizardForm;
    Left := ScaleX(400);
    Top := ScaleY(366);
    Width:= ScaleX(75);
    Height:= ScaleY(25);
  end;

  with WizardForm.BackButton do
  begin
    Parent := WizardForm;
    Left := ScaleX(300);
    Top := ScaleY(366);
    Width:= ScaleX(75);
    Height:= ScaleY(25);
  end;

  StartButton := TNewButton.Create(WizardForm);
  with StartButton do
  begin
    Parent := WizardForm;
    Left := ScaleX(500);
    Top := ScaleY(366);
    Width:= ScaleX(75);
    Height:= ScaleY(25);
    Caption:=ExpandConstant('{cm:StartButton}');
    OnClick:=@StartButtonClick;
  end;

  //////////////////////////////////////////////////////
  WelcomeLabel:= TLabel.Create(WizardForm);
  with WelcomeLabel do
  begin
    AutoSize:= false;
    Parent := Frame;
    Alignment := taCenter;
    Font.Size:=14;
    Top := ScaleY(95);
    Left := ScaleX(30);
    Width := ScaleX(600);
    Height := ScaleX(100);
    Caption :=ExpandConstant('{cm:WelcomeLabel}');
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  WelcomeLabel1:= TLabel.Create(WizardForm);
  with WelcomeLabel1 do
  begin
    AutoSize:= false;
    Parent := Frame;
    Alignment := taCenter;
    Font.Size:=16;
    Top :=WelcomeLabel.Top+ScaleY(30);
    Left := ScaleX(30);
    Width := ScaleX(600);
    Height := ScaleX(100);
    Caption := '{#AppName}';
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  WelcomeLabel2:= TLabel.Create(WizardForm);
  with WelcomeLabel2 do
  begin
    Parent := Frame;
    AutoSize:= false;
    Font.Name := '{#FontName}';
    Font.Size:=10;
    Alignment := taCenter;
    Top :=WelcomeLabel1.Top+ScaleY(100);
    Left := ScaleX(30);
    Width := ScaleX(600);
    Height := ScaleX(200);
    Transparent:= true;
    WordWrap:= true;
    Caption :=ExpandConstant('{cm:WelcomeLabel2}');
    Transparent:= True;
  end;
  //////////////////////////////////////////////////////
  Panel1 := TPanel.Create(WizardForm);
  with Panel1 do
  begin
    Parent := Frame;
    Left := ScaleX(10);
    Top := ScaleY(92);
    Width := ScaleX(630);
    Height := ScaleY(136);
    BevelInner := bvSpace;
    BevelOuter := bvLowered;
    ParentBackground := False;
    Color := 13948116;
  end;

  BevelPanel1 := TBevel.Create(WizardForm);
  with BevelPanel1 do
  begin
    Parent := Panel1;
    Left := ScaleX(492);
    Top := ScaleX(1);
    Width := ScaleX(2);
    Height := Panel1.Height-ScaleY(2);
  end;
  //////////////////////////////////////////////////////
  Panel2 := TPanel.Create(WizardForm);
  with Panel2 do
  begin
    Parent := Frame;
    Left := ScaleX(10);
    Top := Panel1.Top+Panel1.Height+ScaleY(15);
    Width := ScaleX(630);
    Height := ScaleY(96);
    BevelInner := bvSpace;
    BevelOuter := bvLowered;
    ParentBackground := False;
    Color := 13948116;
  end;

  BevelPanel2 := TBevel.Create(WizardForm);
  with BevelPanel2 do
  begin
    Parent := Panel2;
    Left := ScaleX(321);
    Top := ScaleX(1);
    Width := ScaleX(2);
    Height := Panel2.Height-ScaleY(2);
  end;
  //////////////////////////////////////////////////////

  Dirlabel:= TLabel.Create(WizardForm);
  with Dirlabel do
  begin
    Parent := Panel1;
    Left := ScaleY(8);
    Top := ScaleX(13);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Dirlabel}');
    Transparent:= True;
  end;
          
  with WizardForm.DirEdit do
  begin
    Parent := Panel1;
    Top := ScaleY(40);
    Left := ScaleX(20);
    Width := ScaleX(360);
    Font.Name := '{#FontName2}';
    //Font.Color := clGreen;
  end;

  with WizardForm.DirBrowseButton do
  begin
    Parent := Panel1;
    Top := WizardForm.DirEdit.Top+ScaleY(-1);
    Left := WizardForm.DirEdit.Width+WizardForm.DirEdit.Left+ScaleX(20);
  end;

  Grouplabel:= TLabel.Create(WizardForm);
  with Grouplabel do
  begin
    Parent := Panel1;
    Left := ScaleY(8);
    Top := WizardForm.DirEdit.Top+WizardForm.DirEdit.Height+ScaleY(12);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Grouplabel}');
    Transparent:= True;
  end;

  with WizardForm.GroupEdit do
  begin
    Parent := Panel1;
    Top := WizardForm.DirEdit.Top+ScaleY(60);
    Left := ScaleX(20);
    Width := ScaleX(360);
    Font.Name := '{#FontName2}';
    //Font.Color := clGreen;
  end;

  with WizardForm.GroupBrowseButton do
  begin
    Parent := Panel1;
    Top := WizardForm.GroupEdit.Top+ScaleY(-1);
    Left := WizardForm.GroupEdit.Width+WizardForm.GroupEdit.Left+ScaleX(20);
  end;
  //////////////////////////////////////////////////////

  TotalSpaceLabel:= TLabel.Create(WizardForm);
  with TotalSpaceLabel do
  begin
    AutoSize:= False;
    Parent := Panel1;
    Left := ScaleX(500);
    Top := ScaleX(13);
    Width := ScaleX(150);
    Height := Panel2.Height-ScaleY(2);
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  FreeSpaceLabel1:= TLabel.Create(WizardForm);
  with FreeSpaceLabel1 do
  begin
    AutoSize:= False;
    Parent := Panel1;
    Left := TotalSpaceLabel.Left;
    Top := TotalSpaceLabel.Top+ScaleX(43);
    Width := ScaleX(150);
    Height := Panel2.Height-ScaleY(2);
    Font.Name := '{#FontName2}';
    Transparent:= True;
    Caption :=ExpandConstant('{cm:Spacelabel1}');
  end;

  FreeSpaceLabel2:= TLabel.Create(WizardForm);
  with FreeSpaceLabel2 do
  begin
    AutoSize:= False;
    Parent := Panel1;
    Left := TotalSpaceLabel.Left+ScaleX(15);
    Top := TotalSpaceLabel.Top+ScaleX(59);
    Width := ScaleX(150);
    Height := Panel2.Height-ScaleY(2);
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  InstallSpacelabel:= TLabel.Create(WizardForm);
  with InstallSpacelabel do
  begin
    AutoSize:= False;
    Parent := Panel1;
    Left := TotalSpaceLabel.Left;
    Top := FreeSpaceLabel1.Top+ScaleX(45);
    Width := ScaleX(150);
    Height := Panel2.Height-ScaleY(2);
    Font.Name := '{#FontName2}';
    Transparent:= True;
  end;

  BmpFile:= TBitmapImage.Create(WizardForm);
  BmpFile.Bitmap.LoadFromFile(ExpandConstant('{tmp}\ok.bmp'));
  BmpFile.SetBounds(ScaleX(500), FreeSpaceLabel2.Top+ScaleY(2), ScaleX(12), ScaleY(12));
  BmpFile.Stretch:= true
  BmpFile.Parent:= Panel1;

  BmpFile1:= TBitmapImage.Create(WizardForm);
  BmpFile1.Bitmap.LoadFromFile(ExpandConstant('{tmp}\no.bmp'));
  BmpFile1.SetBounds(ScaleX(500), FreeSpaceLabel2.Top+ScaleY(1), ScaleX(12), ScaleY(12));
  BmpFile1.Stretch:= true
  BmpFile1.Parent:= Panel1;

  WizardForm.DirEdit.OnChange:=@DirEditOnChange;
  //////////////////////////////////////////////////////
  Iconslabel:= TLabel.Create(WizardForm);
  with Iconslabel do
  begin
    AutoSize:= False;
    Parent := Panel2;
    Left := ScaleY(8);
    Top := ScaleX(13);
    Width := ScaleX(150);
    Height := ScaleY(20);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Iconslabel}');
    Transparent:= True;
  end;

    Desktop:=TCheckBox.Create(WizardForm);
    with Desktop do begin
      Parent:=Panel2;
      Caption :=ExpandConstant('{cm:Desktop}');
      Left:=ScaleX(13);
      Top:=Iconslabel.Top+Iconslabel.Height;
      Width:=ScaleX(300);
      Height:=ScaleY(15);
      Checked:=True;
    end;

    StartMenu:=TCheckBox.Create(WizardForm);
    with StartMenu do begin
      Parent:=Panel2;
      Caption :=ExpandConstant('{cm:StartMenu}');
      Left:=Desktop.Left;
      Top:=Desktop.Top+Desktop.Height+ScaleY(5);
      Width:=ScaleX(300);
      Height:=ScaleY(15);
      Checked:=True;
      OnClick:= @StartMenuOnClick;
    end;

    QuickLaunch:=TCheckBox.Create(WizardForm);
    with QuickLaunch do begin
      Parent:=Panel2;
      Caption :=ExpandConstant('{cm:QuickLaunch}');
      Left:=Desktop.Left;
      Top:=StartMenu.Top+StartMenu.Height+ScaleY(5);
      Width:=ScaleX(300);
      Height:=ScaleY(15);
      Checked:=True;
    end;
  //////////////////////////////////////////////////////
  Compslabel:= TLabel.Create(WizardForm);
  with Compslabel do
  begin
    AutoSize:= False;
    Parent := Panel2;
    Left := BevelPanel2.Left+ScaleY(8);
    Top := ScaleX(13);
    Width := ScaleX(150);
    Height := ScaleY(20);
    Font.Name := '{#FontName2}';
    Caption :=ExpandConstant('{cm:Compslabel}');
    Transparent:= True;
  end;

    DirectX:=TCheckBox.Create(WizardForm);
    with DirectX do begin
      Parent:=Panel2;
      Caption :=ExpandConstant('{cm:DirectX}');
      Left := BevelPanel2.Left+ScaleY(13);
      Top:=Compslabel.Top+Compslabel.Height;
      Width:=ScaleX(300);
      Height:=ScaleY(15);
      TabOrder:=0;
      Checked:=false;
    end;   

    VCRedist:=TCheckBox.Create(WizardForm);
    with VCRedist do begin
      Parent:=Panel2;
      Caption :=ExpandConstant('{cm:VCRedist}');
      Left := BevelPanel2.Left+ScaleY(13);
      Top:=DirectX.Top+DirectX.Height+ScaleY(5);
      Width:=ScaleX(300);
      Height:=ScaleY(15);
      TabOrder:=0;
      Checked:=false;
    end;

    dotNetFx40:=TCheckBox.Create(WizardForm);
    with dotNetFx40 do begin
      Parent:=Panel2;
      Caption :=ExpandConstant('{cm:dotNetFx40}');
      Left := BevelPanel2.Left+ScaleY(13);
      Top:=VCRedist.Top+VCRedist.Height+ScaleY(5);
      Width:=ScaleX(300);
      Height:=ScaleY(15);
      TabOrder:=0;
      Checked:=false;
    end;
  //////////////////////////////////////////////////////
  Panel3 := TPanel.Create(WizardForm);
  with Panel3 do
  begin
    Parent := Frame;
    Left := ScaleX(10);
    Top := ScaleY(159);
    Width := ScaleX(630);
    Height := ScaleY(180);
    BevelInner := bvSpace;
    BevelOuter := bvLowered;
    ParentBackground := False;
    Color := 13948116;
  end;

  PercentsLabel:= TLabel.Create(WizardForm);
  with PercentsLabel do
  begin
    Top := ScaleY(40);
    Left := ScaleX(40);
    Width := ScaleX(150);
    AutoSize:= False;
    Transparent := True;
    //Parent:= WizardForm.InstallingPage;
    Parent := Panel3;
    Font.Name := '{#FontName2}';
   end;

  with WizardForm.StatusLabel do
  begin
    Top := ScaleY(65);
    Left := ScaleX(40);
    Parent := Panel3;
    Font.Name := '{#FontName2}';
  end;

  with WizardForm.ProgressGauge do
  begin
    Top := ScaleY(90);
    Left := ScaleX(40);
    Width := ScaleX(550);
    Parent := Panel3;
  end;

  with WizardForm.FilenameLabel do
  begin
    Top := ScaleY(120);
    Left := ScaleX(40);
    Left:= WizardForm.StatusLabel.Left;
    Width := ScaleX(562);
    Parent := Panel3;
    Font.Name := '{#FontName2}';
  end;
end;

procedure WFDeInit;
begin
  gdipShutDown;
end;

procedure InitializeWizard();
begin
  InitializeWFont;
  WizardFormInit;
  RedesignWizardForm;
  Win7TaskBar20();
end;

procedure HideComponents;
begin
  ImgSetVisibility(BigOk,False);
  ImgSetVisibility(BigWarn,False);
  ImgSetVisibility(BigFail,False);
  ImgSetVisibility(BigInst,False);
  WelcomeLabel.Hide;
  WelcomeLabel1.Hide;
  WelcomeLabel2.Hide;
  Panel1.Hide;
  Panel2.Hide;
  Panel3.Hide;
  StartButton.Hide;
end;

Procedure CurPageChanged(CurPageID: Integer);
 Begin
  HideComponents;
case CurPageID of

 wpWelcome:
  begin
  WelcomeLabel.Show;
  WelcomeLabel1.Show;
  WelcomeLabel2.Show;
  end;

 wpSelectDir:
  begin
  Panel1.Show;
  Panel2.Show;
  TotalSpaceLabel.Show;
  If WizardForm.FindComponent('NextButton') is TButton then
  TButton(WizardForm.FindComponent('NextButton')).Caption:=ExpandConstant('{cm:NextButton}');
  DirEditOnChange(nil)
  end;

 wpInstalling:
  begin
  WelcomeLabel1.Show;
  WelcomeLabel1.Caption:=ExpandConstant('{cm:WelcomeLabel3}');
  ImgSetVisibility(BigInst,True);
  Panel3.Show;
  end;


 wpFinished:
  begin
  WelcomeLabel1.Show;
  WelcomeLabel1.Caption:='{#AppName}';
  WelcomeLabel2.Show;
  WelcomeLabel2.Caption:=ExpandConstant('{cm:WelcomeLabel4}');
  ImgSetVisibility(BigOk,True);
  StartButton.Show;
  end;
  end;
  ImgApplyChanges(Frame.Handle);
 end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then
  begin
  PercentsTimer:= SetTimer(0, 0, 100, WrapTimerProc(@PercentsProc, 4));
  end;
  if CurStep = ssPostInstall then
  begin
//Source: "ARIALUNI.TTF"; DestDir: "{fonts}"; FontInstall: "Arial Unicode MS"; Flags: onlyifdoesntexist uninsneveruninstall
  end;
end;

procedure DeinitializeSetup;
begin
  WFDeInit;
  RemoveFontMemResourceEx(fh);
  RemoveFontMemResourceEx(fh2);
  WizardForm.Free;
  KillTimer(0, PercentsTimer);
  gdipShutdown;
end;
 

Nemko

Дилетант
Модератор
EvilAlex, botva'a не инициализировалась, поэтому и ошибка gdipShutDown. Решение, думаю, сделать переменную типа Boolean в InitializeWizard (ну или где создаются графические элементы) которая принимает значение True если Setup дошел до стадии создания элементов. И в WFDeInit задать условие: if MyBoolean then gdipShutDown;
 
Сверху