Вопрос How to create checkbox at finished page to install DirectX?

  • Автор темы Автор темы nizcoz
  • Дата начала Дата начала
This ?

Код:
#define AppName "Example"
#define AppVers "1.5"
; DirectX directory
#define DirectX "Redist\DirectX.exe"

[Setup]
AppName={#AppName}
AppVersion={#AppVers}
DefaultDirName={sd}\{#AppName}

[Code]
var
  RunCheckBox: TCheckBox;

procedure ClickBox(Sender: TObject);
begin
    if RunCheckBox.Checked then RunCheckBox.Caption:=#$0020#$0052#$0075#$006E#$0020#$0044#$0069#$0072#$0065#$0063#$0074#$0058
  else RunCheckBox.Caption:=#$0020#$0044#$006F#$0020#$006E#$006F#$0074#$0020#$0072#$0075#$006E#$0020#$0044#$0069#$0072#$0065#$0063#$0074#$0058
end;

procedure Initializewizard;
begin
 RunCheckBox:=TCheckBox.Create(WizardForm.FinishedPage);
with RunCheckBox do
begin
  Parent:=WizardForm.FinishedPage;
  Top:=WizardForm.YesRadio.Top-WizardForm.YesRadio.Height;
  Left:=WizardForm.YesRadio.Left;
  Width:=RunCheckBox.Width+20;
  OnClick:=@ClickBox;
  Checked:=True;
end;
end;

procedure DeinitializeSetup;
var
  ResultCode: Integer;
begin
  if RunCheckBox.Checked then begin
  Exec(ExpandConstant('{src}\{#DirectX}'),'','', SW_SHOWNORMAL, ewNoWait, ResultCode);
end;
end;
 
I hope it will not be difficult to understand. ;) There are arrays and cycles and different operators.

Код:
#define AppName        "Example"
#define AppVersion     "1.5"

; DirectX directory
#define DirectX        "Redist\DirectX.exe"
; VC Redist directory
#define VC_Redist_x86  "Redist\vcredist_x86.exe"
#define VC_Redist_x64  "Redist\vcredist_x64.exe"

[Setup]
AppName={#AppName}
AppVersion={#AppVersion}
DefaultDirName={sd}\{#AppName}

[Code]
var
  CheckBox: array[1..2] of TCheckBox;

procedure ClickBox(Sender: TObject);
begin
  case Sender of
  CheckBox[1]: begin
    if CheckBox[1].Checked then CheckBox[1].Caption:=#$0020#$0052#$0075#$006E#$0020#$0044#$0069#$0072#$0065#$0063#$0074#$0058
    else CheckBox[1].Caption:=#$0020#$0044#$006F#$0020#$006E#$006F#$0074#$0020#$0072#$0075#$006E#$0020#$0044#$0069#$0072#$0065#$0063#$0074#$0058
end;
  CheckBox[2]: begin
    if not IsWin64  then begin
      if CheckBox[2].Checked then CheckBox[2].Caption:=#$0020#$0052#$0075#$006E#$0020#$0056#$0043#$0020#$0052#$0065#$0064#$0069#$0073#$0074#$0020#$0033#$0032#$002D#$0062#$0069#$0074
      else CheckBox[2].Caption:=#$0020#$0044#$006F#$0020#$006E#$006F#$0074#$0020#$0072#$0075#$006E#$0020#$0056#$0043#$0020#$0052#$0065#$0064#$0069#$0073#$0074#$0020#$0033#$0032#$002D#$0062#$0069#$0074
end;
    if IsWin64 then begin
      if CheckBox[2].Checked then CheckBox[2].Caption:=#$0020#$0052#$0075#$006E#$0020#$0056#$0043#$0020#$0052#$0065#$0064#$0069#$0073#$0074#$0020#$0036#$0034#$002D#$0062#$0069#$0074
      else CheckBox[2].Caption:=#$0020#$0044#$006F#$0020#$006E#$006F#$0074#$0020#$0072#$0075#$006E#$0020#$0056#$0043#$0020#$0052#$0065#$0064#$0069#$0073#$0074#$0020#$0036#$0034#$002D#$0062#$0069#$0074
end;
end;
end;
end;

procedure Initializewizard;
var
  i: integer;
begin
  for i:=1 to 2 do begin
    CheckBox[i]:=TCheckBox.Create(WizardForm.FinishedPage);
    with CheckBox[i] do
    begin
      Parent:=WizardForm.FinishedPage;
      Top:=(WizardForm.YesRadio.Top-50)+(i*WizardForm.YesRadio.Height+5);
      Left:=WizardForm.YesRadio.Left;
      Width:=WizardForm.YesRadio.Width;
      OnClick:=@ClickBox;
      Checked:=True;
    end;
  end;
end;

procedure DeinitializeSetup;
var
  ResultCode: Integer;
begin
  if CheckBox[1].Checked then Exec(ExpandConstant('{src}\{#DirectX}'),'','', SW_SHOWNORMAL, ewNoWait, ResultCode);
  if CheckBox[2].Checked and not IsWin64 then Exec(ExpandConstant('{src}\{#VC_Redist_x86}'),'','', SW_SHOWNORMAL, ewNoWait, ResultCode);
  if CheckBox[2].Checked and IsWin64 then Exec(ExpandConstant('{src}\{#VC_Redist_x64}'),'','', SW_SHOWNORMAL, ewNoWait, ResultCode);
  WizardForm.Free;
end;
 
Последнее редактирование:
@Nemko First, Thanks a lot!!!! If I choose to install directx and vcredist64, is it possible that the installers to run one at a time? (both are executed at the same time).
 
If I choose to install directx and vcredist64, is it possible that the installers to run one at a time? (both are executed at the same time).
nizcoz, replace it.
Код:
procedure DeinitializeSetup;
var
  ResultCode: Integer;
begin
  if CheckBox[1].Checked then Exec(ExpandConstant('{src}\{#DirectX}'),'','', SW_SHOWNORMAL, ewWaitUntilTerminated, ResultCode);
  if CheckBox[2].Checked and not IsWin64 then Exec(ExpandConstant('{src}\{#VC_Redist_x86}'),'','', SW_SHOWNORMAL, ewNoWait, ResultCode);
  if CheckBox[2].Checked and IsWin64 then Exec(ExpandConstant('{src}\{#VC_Redist_x64}'),'','', SW_SHOWNORMAL, ewNoWait, ResultCode);
  WizardForm.Free;
end;
 
Назад
Сверху