How do I detect in the Windows Registry if a user has .Net Framework installed? I am not looking for a .Net based solution, as the query is from InnoSetup.
I know from reading another post here on Stack Overflow that .Net Framework is an inplace upgrade to 4.0.
I already know how to check if a user has version 4.0 installed on the system, namely by checking the following:
function FindFramework(): Boolean;
var
bVer4x0: Boolean;
bVer4x0Client: Boolean;
bVer4x0Full: Boolean;
bSuccess: Boolean;
iInstalled: Cardinal;
begin
Result := False;
bVer4x0Client := False;
bVer4x0Full := False;
bVer4x0 := RegKeyExists(HKLM, 'SOFTWARE\Microsoft\.NETFramework\policy\v4.0');
bSuccess := RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4 \Client', 'Install', iInstalled);
if (1 = iInstalled) AND (True = bSuccess) then bVer4x0Client := True;
bSuccess := RegQueryDWordValue(HKLM, 'Software\Microsoft\NET Framework Setup\NDP\v4 \Full', 'Install', iInstalled);
if (1 = iInstalled) AND (True = bSuccess) then bVer4x0Full := True;
if (True = bVer4x0Full) then begin
Result := True;
end;
end;
I checked the registry and there is no v4.5 folder, which makes sense if .Net Framework 4.5 is an inplace upgrade. Still, the Control Panel Programs and Features includes the listing.
I know that probably "issuing dotNetFx45_Full_setup.exe /q" will have no bad effect if installing on a system that already has version 4.5, but I still would like to not install the upgrade if the upgrade already exists, faster and less problems.
I wanted to share the actual Inno Setup code that I wrote, which specifically answers my question. Thanks to the previous answer for pushing me in the right direction.
The NextButtonClick() event would call this function right after the welcome.
The File and Run sections merely contain a function which uses the Check and checks that variable.
I will state the obvious that one has to make sure that .Net Framework 4.0 is installed first and then check / install .Net Framework 4.5.
Now, if System.Data.SQLite.org would come out with a Visual Studio 2012 compliant version, I can check off my other big upgrade task.
Update: 2010.10.11 (Per TLana's comment) Note: I decided to leave the original code, because I figure that others would like to see where I started. The code below is where I am at now. The code below also uses the proper registry location and checks for both .Net 4.0 and the new .Net 4.5. What about the future? When .Net 6.0 and 6.5 comes out, all that is needed is change the 4 to a 6, unless Microsoft changes the formula. it seems that the .5 upgrade is not a new framework but an upgrade to the existing one.
How to: Determine Which .NET Framework Versions Are Installed
http://msdn.microsoft.com/en-us/library/hh925568.aspx
How to: Determine Which .NET Framework Updates Are Installed
http://msdn.microsoft.com/en-us/library/hh925567.aspx
The code provided in these two articles works through Version 4.5 of the Framework. The update detection code identifies all routine updates, security updates and hotfixes.