Advertisement
MALWAREz

Inno Setup: Check for .NET Desktop Runtime

Dec 23rd, 2023 (edited)
1,253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.51 KB | None | 0 0
  1. function CheckDotNetVersion: Boolean;
  2. var
  3.   DotNetVersion: TFindRec;
  4. begin
  5.   Result := False;
  6.   if FindFirst(ExpandConstant('{pf64}')+'\dotnet\host\fxr\*', DotNetVersion) then
  7.   begin
  8.     try
  9.       repeat                                                                                                                                                                              
  10.         StringChangeEx(DotNetVersion.Name, '.', '', True);
  11.         if (Copy(DotNetVersion.Name, 1, 1) = '8') or ((Copy(DotNetVersion.Name, 1, 1) = '7') and (StrToInt(DotNetVersion.Name) >= 7014)) then
  12.         begin
  13.           Result := True;
  14.           Break;
  15.         end;
  16.       until not FindNext(DotNetVersion);
  17.     finally
  18.       FindClose(DotNetVersion);
  19.     end;
  20.   end;
  21. end;
  22.  
  23. procedure CurStepChanged(CurStep: TSetupStep);
  24. var
  25.   ResultCode: Integer;
  26.   StatusText: string;
  27. begin
  28.   if (CurStep = ssPostInstall) then
  29.   begin
  30.     if not CheckDotNetVersion then
  31.     begin
  32.       StatusText := WizardForm.StatusLabel.Caption;
  33.       WizardForm.StatusLabel.Caption := CustomMessage('dotNETInstalling');
  34.       WizardForm.ProgressGauge.Style := npbstMarquee;
  35.       try
  36.         if not Exec(ExpandConstant('{tmp}\dotnet.exe'), '/q', '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
  37.           MsgBox(CustomMessage('dotNETFailed') + IntToStr(ResultCode) + '.', mbError, MB_OK);
  38.       finally
  39.         WizardForm.StatusLabel.Caption := StatusText;
  40.         WizardForm.ProgressGauge.Style := npbstNormal;
  41.       end;
  42.     end;
  43.   end;
  44. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement