Search code examples
.netinno-setuppascalscript

Report installed .NET Framework version during install with Inno Setup


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.

Solution

  • 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.