1
votes

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?

1
Try to search here.TLama
hi TLama,i want to call Framework45IsNotInstalled function in InitializeWizard,because in initializewizard only i declared itd_downloadafter(10), i want to call framework45IsNotInstaller function before it_downloadafter(10). how it is possible?Lokesh
Ah, I see. You want to conditionally download .NET framework installer only if it's not already installed from InitializeWizard event method; if so, then this way.TLama
Thank you very much TLama, this is what i am trying .Finally i got it.Lokesh
Don't hardcode page ids. They may change in future versions of Inno or your own script. Use the defined constants for standard pages or the Id property for your own pages.Miral

1 Answers

1
votes

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