2
votes

I am experimenting with Inno Setup in preparation for creating an installer. My first attempt is to report back to the user which .NET Framework is currently installed. I came up with the following script, which installs a token exe but it does not show the message box that I wanted to display the installed Framework version.

[Setup]
AppName=NETFramework_Test
AppVersion=1.0.0
DefaultDirName=c:\al\NetFWTest\test
WizardStyle=modern
OutputDir=c:\al\NetFWTest

[Files]
Source: "c:\al\computer\miscsmallapps\tmpdir\tmpdir.exe"; DestDir: "{app}";
[Code]
var
  VersionNum: cardinal;

begin
  if RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full',
       'Version', VersionNum) then
    begin
      MsgBox('The installed .NET Framework version:' + IntToStr(VersionNum),
        mbInformation, MB_OK);
    end
  else
    begin
      MsgBox('Error reading the Registry...', mbInformation, MB_OK);
    end;
end.
2

2 Answers

1
votes

Why do this manually when you can already use IsDotNetInstalled?

For example:

[Code]
// InitializeSetup is called when the setup is starting.
function InitializeSetup(): Boolean;
begin
  Result := True;
  if not IsDotNetInstalled(net462, 0) then
  begin
    MsgBox('The required .NET Framework version 4.6.2 is not installed.',
      mbError, MB_OK)
    Result := False;
  end;
end;
0
votes

You need to call your code from some Inno Setup event function, like InitializeSetup.

For an example, see Inno Setup - How can I check system specs before/during installation?


Also, the Version value is string, so you need to use RegQueryStringValue.