How To Check .Net Framework Version Installed ???
1. Query the UserAgent string of Internet Explorer web browser. This is the easier way, I think, as every Windows bundled with IE!
Although you need to remember this simple, one line JavaScript:
javascript:alert(navigator.userAgent)
Copy and paste that line of JavaScript code to IE Address bar and press ENTER key, you will see a pop-up dialog box with .NET version installed.
2. Navigate to this Windows Registry path
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP
The major version number of each .Net framework releases installed can be found at this Registry path. Click the major version number key and there is a string value called “version” on the right-pane that reports the full version number of that .Net framework.
3.Navigate to the Registry path that keeps the IE User Agent String:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
4.C:\WINNT\Microsoft.NET\Framework /C:\Windows\Microsoft.NET\Framework
directory will have the directories for the version you have installed on your machine.
To be generic , C:\%windir%\Microsoft.NET\Framework will have the directories for the version you have installed on your machine.
5. Query GetCORSystemDirectory Function() API of MsCorEE.dll regarding the the install directory for the version of the runtime that is loaded in the current process.
Sample Code:
[C#]
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
[DllImport("mscoree.dll")]
// Declaration
internal static extern void GetCORSystemDirectory([MarshalAs(UnmanagedType.LPTStr)]
System.Text.StringBuilder Buffer,
int BufferLength, ref int Length);
// Gets the path to the Framework directory.
System.Text.StringBuilder sb = new System.Text.StringBuilder(1024);
int size;
// returned value in size can be ignored
GetCORSystemDirectory(sb, sb.Capacity, ref size);
...
...
...
Ref:
http://www.walkernews.net/2008/05/16/how-to-check-net-framework-version-installed/
http://blogs.msdn.com/astebner/archive/2004/09/14/229802.aspx