.NET Framework as a prerequisite for installation using Inno-Setup

I have an application that I have to check if .NET FW 3.5 is installed. If it is already installed, I want to open a mailbox that asks the user to download it from the Microsoft website and stop the installation.

I found the following code. Can you tell me:

a) Where do I get this function from? b) Do I have to check if .NET FW 3.5 or higher is installed? For example, if FW 4.0 is installed - do you need to install 3.5?

thanks

function IsDotNET35Detected(): Boolean; var ErrorCode: Integer; netFrameWorkInstalled : Boolean; isInstalled: Cardinal; begin result := true; // Check for the .Net 3.5 framework isInstalled := 0; netFrameworkInstalled := RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', isInstalled); if ((netFrameworkInstalled) and (isInstalled <> 1)) then netFrameworkInstalled := false; if netFrameworkInstalled = false then begin if (MsgBox(ExpandConstant('{cm:dotnetmissing}'), mbConfirmation, MB_YESNO) = idYes) then begin ShellExec('open', 'http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&DisplayLang=en', '','',SW_SHOWNORMAL,ewNoWait,ErrorCode); end; result := false; end; end; 
+7
source share
1 answer

If you want to perform a check at installation start, but until the wizard form appears, use the InitializeSetup event handler for this. When you return False to this handler, the installation will be aborted when the True setup starts. Here's the slightly optimized script you posted:

 [Setup] AppName=My Program AppVersion=1.5 DefaultDirName={pf}\My Program [CustomMessages] DotNetMissing=.NET Framework 3.5 is missing. Do you want to download it ? Setup will now exit! [Code] function IsDotNET35Detected: Boolean; var ErrorCode: Integer; InstallValue: Cardinal; begin Result := True; if not RegQueryDWordValue(HKLM, 'SOFTWARE\Microsoft\NET Framework Setup\NDP\v3.5', 'Install', InstallValue) or (InstallValue <> 1) then begin Result := False; if MsgBox(ExpandConstant('{cm:DotNetMissing}'), mbConfirmation, MB_YESNO) = IDYES then ShellExec('', 'http://www.microsoft.com/downloads/details.aspx?FamilyID=333325fd-ae52-4e35-b531-508d977d32a6&DisplayLang=en', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode); end; end; function InitializeSetup: Boolean; begin Result := IsDotNET35Detected; end; 
+6
source

All Articles