Advertisement
Combreal

restartConsent.iss

May 26th, 2020
1,772
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 3.14 KB | None | 0 0
  1. [Setup]
  2. AppName=My Program
  3. AppVersion=1.5
  4. DefaultDirName={pf}\My Program
  5. AlwaysRestart=no
  6. DisableFinishedPage=yes
  7.  
  8.  
  9. [CustomMessages]
  10. restart_Caption0=Yes restart now
  11. restart_Caption1=No restart later
  12.  
  13.  
  14. [Code]
  15. var
  16.     RestartRadioButton: TRadioButton;
  17.     PostponeRestartRadioButton: TRadioButton;
  18.     Page: TWizardPage;
  19.     FirstLabel: TLabel;
  20.     FirstLabelB: TLabel;
  21.     LabelText: string;
  22.     LabelTextB: string;
  23.  
  24.    
  25. function NeedRestart(): Boolean;
  26. begin
  27.   Result := True;
  28. end;
  29.  
  30. function authentication_form_NextButtonClick(Page: TWizardPage): Boolean;
  31. begin
  32.   if PostponeRestartRadioButton.Checked then
  33.   begin
  34.     MsgBox('The computer needs to be restarted before Setup can continue.', mbError, MB_OK);
  35.     RestartRadioButton.Checked := True
  36.     Result := False;
  37.   end
  38.   else
  39.   begin
  40.     NeedRestart();
  41.     Result := True;
  42.   end
  43. end;
  44.  
  45. function CreateDataPage(PreviousPageId: Integer): Integer;  
  46. begin
  47.   if (FileExists('C:\Windows\System32\bash.exe')) then
  48.   begin
  49.       LabelText := 'WSL is already installed.'
  50.   end
  51.   else
  52.   begin
  53.       LabelText := 'WSL was installed.'
  54.   end;
  55.  
  56.   LabelTextB := 'The computer needs to be restarted before Setup can continue.'
  57.  
  58.   Page :=CreateCustomPage(PreviousPageId,'WSL installation', '');
  59.  
  60.  
  61.     FirstLabel :=TLabel.Create(Page);
  62.     with FirstLabel do
  63.     begin
  64.         Parent :=Page.Surface;
  65.         Caption :=ExpandConstant(LabelText);
  66.         Left :=ScaleX(16);
  67.         Top :=ScaleY(50);
  68.         Width :=ScaleX(250);
  69.         Height :=ScaleY(17);
  70.     end;
  71.  
  72.     FirstLabelB :=TLabel.Create(Page);
  73.     with FirstLabelB do
  74.     begin
  75.         Parent :=Page.Surface;
  76.         Caption :=ExpandConstant(LabelTextB);
  77.         Left :=ScaleX(16);
  78.         Top :=ScaleY(84);
  79.         Width :=ScaleX(500);
  80.         Height :=ScaleY(17);
  81.     end;
  82.  
  83.     RestartRadioButton := TRadioButton.Create(Page);
  84.     with RestartRadioButton do
  85.     begin
  86.         Parent := Page.Surface;
  87.         Caption := ExpandConstant('{cm:restart_Caption0}');
  88.         Left := ScaleX(16);
  89.         Top := ScaleY(112);
  90.         Width := ScaleX(193);
  91.         Height := ScaleY(17);
  92.         TabOrder := 2;
  93.         Checked := true;
  94.     end;
  95.  
  96.     PostponeRestartRadioButton := TRadioButton.Create(Page);
  97.     with PostponeRestartRadioButton do
  98.     begin
  99.         Parent := Page.Surface;
  100.         Caption := ExpandConstant('{cm:restart_Caption1}');
  101.         Left := ScaleX(16);
  102.         Top := ScaleY(140);
  103.         Width := ScaleX(193);
  104.         Height := ScaleY(17);
  105.         TabOrder := 2;
  106.     end;
  107.  
  108.     with Page do
  109.     begin
  110.        OnNextButtonClick := @authentication_form_NextButtonClick;
  111.        if PostponeRestartRadioButton.Checked then
  112.        begin
  113.          RestartRadioButton.Checked := false
  114.        end;
  115.        if RestartRadioButton.Checked then
  116.        begin
  117.          PostponeRestartRadioButton.Checked := false
  118.        end;
  119.     end;
  120.  
  121.     Result :=Page.ID;
  122.  
  123. end;
  124.  
  125. procedure InitializeWizard();
  126. begin
  127.     CreateDataPage(wpInstalling);
  128. end;
  129.  
  130. procedure CurPageChanged(CurPageID: Integer);
  131. begin
  132.   if CurPageID = Page.ID then begin
  133.     WizardForm.NextButton.Caption := 'Finish'  
  134.   end;
  135. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement