title: .NET Framework as a pre-requisite for installation with Inno-Setup
body: <p>I have an application I have to check if .NET FW 3.5 has already installed. If already installed, I want to open a messagebox that asks the user to download it from Microsoft website and stop the installation.</p>
  
  <p>I found the following code. Can you tell me please:</p>
  
  <p>a) Where should I call this function from?
  b) Should I check if .NET FW 3.5 <strong>or higher version</strong> is already installed? e.g. If FW 4.0 installed - is that necessary to install 3.5?</p>
  
  <p>Thank you</p>
  
  <pre><code>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 &lt;&gt; 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&amp;DisplayLang=en',
        '','',SW_SHOWNORMAL,ewNoWait,ErrorCode);
      end;
      result := false;
    end;
  
  end;
  </code></pre>