1
votes

I just noticed that Inno Setup 6.0.4 is now out and that it has a new IsDotNetInstalled function.

At the moment I have been using this script to see if 4.6.2 is installed:

{ Determines if .NET 4.6.2 (or higher) is installed }
function IsDotNetDetected(): boolean;
var
    strKey64: string;
    strKey86: string;
    dwInstalled: cardinal;
begin
  strKey64 := 'SOFTWARE\Wow6432Node\Microsoft\NET Framework Setup\NDP\v4\Full';
  strKey86 := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full';

  result := false; { Assume .NET Framework 4.6.2 is not installed }

  { For more information, see: }
  { http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx#net_b }
  if(Is64BitInstallMode()) then begin
    if (RegValueExists(HKLM, strKey64, 'Release')) then begin
      RegQueryDWordValue(HKLM, strKey64, 'Release', dwInstalled);
      if(dwInstalled >= 378675) then begin
        result := true;
      end;
    end;
  end
  else begin
    if (RegValueExists(HKLM, strKey86, 'Release')) then begin
      RegQueryDWordValue(HKLM, strKey86, 'Release', dwInstalled);
      if(dwInstalled >= 378675) then begin
        result := true;
      end;
    end;
  end;
end;

The above code was called here:

function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
  result := '';

  dotNetNeeded := not IsDotNetDetected();

  if(dotNetNeeded) then begin
    if (MsgBox(ExpandConstant('{cm:DotNet_NeedToDownload}'),
                      mbConfirmation, MB_OKCANCEL) = IDCANCEL) then begin
      result := ExpandConstant('{cm:DotNet_InstallAborted}');
      Abort();
    end;
  end;

  if (bDownloadHelpDocSetup) then
    DoDeleteFile(ExpandConstant('{app}\MeetSchedAssist.chm'));
end;

I have read the help topic and it seems that I can simplify this code to:

function PrepareToInstall(var NeedsRestart: Boolean): String;
begin
  result := '';

  dotNetNeeded := not IsDotNetInstalled(net462, 0);

  if(dotNetNeeded) then begin
    if (MsgBox(ExpandConstant('{cm:DotNet_NeedToDownload}'),
                      mbConfirmation, MB_OKCANCEL) = IDCANCEL) then begin
      result := ExpandConstant('{cm:DotNet_InstallAborted}');
      Abort();
    end;
  end;

  if (bDownloadHelpDocSetup) then
    DoDeleteFile(ExpandConstant('{app}\MeetSchedAssist.chm'));
end;

I notice that the sample code is also using this to format the error message:

FmtMessage(SetupMessage(msgWinVersionTooLowError), ['.NET Framework', '4.6.2'])

What is the MinServicePack parameter here?

Thanks for the clarification.

1

1 Answers

1
votes

I found the answer about MinServicePack here. It states:

// service -- Specify any non-negative integer for the required service pack level:
//    0               No service packs required
//    1, 2, etc.      Service pack 1, 2, etc. required