Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3321930
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:07:20+00:00 2026-05-17T23:07:20+00:00

I have a component that requires .NET 4.0 to run, how can my Inno

  • 0

I have a component that requires .NET 4.0 to run, how can my Inno Setup installer verify that it is installed, and if not, prompt the user to install it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:07:20+00:00Added an answer on May 17, 2026 at 11:07 pm

    The InitializeSetup function is called when the Inno Setup executable is run. Inserting this code for a custom script should do what you want:

    function IsDotNetDetected(version: string; service: cardinal): boolean;
    // Indicates whether the specified version and service pack of the .NET Framework is installed.
    //
    // version -- Specify one of these strings for the required .NET Framework version:
    //    'v1.1'          .NET Framework 1.1
    //    'v2.0'          .NET Framework 2.0
    //    'v3.0'          .NET Framework 3.0
    //    'v3.5'          .NET Framework 3.5
    //    'v4\Client'     .NET Framework 4.0 Client Profile
    //    'v4\Full'       .NET Framework 4.0 Full Installation
    //    'v4.5'          .NET Framework 4.5
    //    'v4.5.1'        .NET Framework 4.5.1
    //    'v4.5.2'        .NET Framework 4.5.2
    //    'v4.6'          .NET Framework 4.6
    //    'v4.6.1'        .NET Framework 4.6.1
    //    'v4.6.2'        .NET Framework 4.6.2
    //    'v4.7'          .NET Framework 4.7
    //    'v4.7.1'        .NET Framework 4.7.1
    //    'v4.7.2'        .NET Framework 4.7.2
    //    'v4.8'          .NET Framework 4.8
    //
    // 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
    var
        key, versionKey: string;
        install, release, serviceCount, versionRelease: cardinal;
        success: boolean;
    begin
        versionKey := version;
        versionRelease := 0;
    
        // .NET 1.1 and 2.0 embed release number in version key
        if version = 'v1.1' then begin
            versionKey := 'v1.1.4322';
        end else if version = 'v2.0' then begin
            versionKey := 'v2.0.50727';
        end
    
        // .NET 4.5 and newer install as update to .NET 4.0 Full
        else if Pos('v4.', version) = 1 then begin
            versionKey := 'v4\Full';
            case version of
              'v4.5':   versionRelease := 378389;
              'v4.5.1': versionRelease := 378675; // 378758 on Windows 8 and older
              'v4.5.2': versionRelease := 379893;
              'v4.6':   versionRelease := 393295; // 393297 on Windows 8.1 and older
              'v4.6.1': versionRelease := 394254; // 394271 before Win10 November Update
              'v4.6.2': versionRelease := 394802; // 394806 before Win10 Anniversary Update
              'v4.7':   versionRelease := 460798; // 460805 before Win10 Creators Update
              'v4.7.1': versionRelease := 461308; // 461310 before Win10 Fall Creators Update
              'v4.7.2': versionRelease := 461808; // 461814 before Win10 April 2018 Update
              'v4.8':   versionRelease := 528040; // 528049 before Win10 May 2019 Update
            end;
        end;
    
        // installation key group for all .NET versions
        key := 'SOFTWARE\Microsoft\NET Framework Setup\NDP\' + versionKey;
    
        // .NET 3.0 uses value InstallSuccess in subkey Setup
        if Pos('v3.0', version) = 1 then begin
            success := RegQueryDWordValue(HKLM, key + '\Setup', 'InstallSuccess', install);
        end else begin
            success := RegQueryDWordValue(HKLM, key, 'Install', install);
        end;
    
        // .NET 4.0 and newer use value Servicing instead of SP
        if Pos('v4', version) = 1 then begin
            success := success and RegQueryDWordValue(HKLM, key, 'Servicing', serviceCount);
        end else begin
            success := success and RegQueryDWordValue(HKLM, key, 'SP', serviceCount);
        end;
    
        // .NET 4.5 and newer use additional value Release
        if versionRelease > 0 then begin
            success := success and RegQueryDWordValue(HKLM, key, 'Release', release);
            success := success and (release >= versionRelease);
        end;
    
        result := success and (install = 1) and (serviceCount >= service);
    end;
    
    function InitializeSetup(): Boolean;
    begin
        if not IsDotNetDetected('v4.6', 0) then begin
            MsgBox('MyApp requires Microsoft .NET Framework 4.6.'#13#13
                'Please use Windows Update to install this version,'#13
                'and then re-run the MyApp setup program.', mbInformation, MB_OK);
            result := false;
        end else
            result := true;
    end;
    

    (Code taken from here: http://www.kynosarges.de/DotNetVersion.html)

    First, it checks for the presence of a registry entry that indicates the version of the .NET framework that is installed. If the registry entry is not present, it prompts the user to download the .NET framework. If the user says Yes, it opens the download URL. (You may have to change the version it specifies in the script to version 4.0.)

    I also came across [this article on CodeProject][1], which may be a more comprehensive and customizable way of doing what you’re looking for, although it may take more work to understand and will have to be modified to work with version 4.0.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that requires resizing of a component that will be scaled
I have custom component that I can place in my layout file (XML) for
Can someone check my .NET code that I have in an InfoPath button to
We have a legacy component that has been converted from VB6 to VB.Net. The
We have an MSI installer for a .Net WinForms app for Windows XP that
We have old .net 1.1 project that is using a third party component. Aparently
I have a form in which the user can choose a component type from
I have a component that I hand over a function public var func :
I have a component that is made up of various components such as a
I have a component that i want to store to an SQLite database. public

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.