Lokesh
Lokesh

Reputation: 359

How to install .net framework 4.5 after download completes from web using innosetup?

I want to download and install the .netframework 4.5 from web using innosetup. I followed these procedure, 1.I downloaded and installed InnoTools Downloader. 2.In InitializeWizard i declared

itd_init;
itd_addfile('http://go.microsoft.com/fwlink/?LinkId=225702',expandconstant('{tmp}\dotNetFx45_Full_x86_x64.exe'));
itd_downloadafter(10);

Where 10 is the curpageId. And in

NextButtonClick(CurPageID: Integer) i added ,
 if CurPageId=104 then begin

     `filecopy(expandconstant('{tmp}\dotNetFx45_Full_x86_x64.exe'),expandconstant('{app}\dotNetFx`45_Full_x86_x64.exe'),false);
     end

*Now what i need to do is,i want to check whether .net framework 4.5 is installed in my pc or not, using the function how can i check *,

function Framework45IsNotInstalled(): Boolean;
var
 bVer4x5: Boolean;
 bSuccess: Boolean;
 iInstalled: Cardinal;
 strVersion: String;
 iPos: Cardinal;
 ErrorCode: Integer;

begin
 Result := True;
 bVer4x5 := False;

 bSuccess := RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Install', iInstalled);
 if (1 = iInstalled) AND (True = bSuccess) then
  begin
    bSuccess := RegQueryStringValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Version', strVersion);
    if (True = bSuccess) then
     Begin
        iPos := Pos('4.5.', strVersion);
        if (0 < iPos) then bVer4x5 := True;

     End
  end;

 if (True = bVer4x5) then begin
    Result := False;
end;
end;

where i need to check this condition, in my side downloading and installing of .netframework 4.5 is happening fine,the only condition i need to check whether .net framework 4.5 is installed or not,before calling this **itd_downloadafter(10)Where 10 is the curpageId.**. Then only download wont happen, if .netframework is already exist in my enduser pc. How can i achieve this task? any ideas?

Upvotes: 1

Views: 3413

Answers (1)

BrutalDev
BrutalDev

Reputation: 6301

The release version numbers in the registry for .NET 4.5 are highlighted in MSDN: http://msdn.microsoft.com/en-us/library/hh925568(v=vs.110).aspx

Your code needs to be modified to look at the 'Release' key in the registry as specified in the MDSN article above and can be simplified just to check for this value.

function Framework45IsNotInstalled(): Boolean;
  var
   bSuccess: Boolean;
   regVersion: Cardinal;

  begin
    Result := True;

    bSuccess := RegQueryStringValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4\Full', 'Release', regVersion);
    if (True = bSuccess) and (regVersion >= 378389) then begin
      Result := False;
    end;
  end;
end;

For a more complete example of checking .NET version numbers with Inno Setup you can also look at the code in this very useful article: http://kynosarges.org/DotNetVersion.html

Upvotes: 1

Related Questions