public static bool CheckIfDotNetFrameworkInstalled(string version)
{
return CheckIfDotNetFrameworkInstalled(version, 0);
}
public static bool CheckIfDotNetFrameworkInstalled(string version, int servicePack)
{
bool isInstalled = false;
RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(string.Format("SOFTWARE//Microsoft//NET Framework Setup//NDP//v{0}", version));
if (registryKey != null)
{
if (Convert.ToInt32(registryKey.GetValue("Install", 0)) == 1)
{
if (servicePack > 0)
{
if (Convert.ToInt32(registryKey.GetValue("SP", 0)) == servicePack)
{
isInstalled = true;
}
}
else
{
isInstalled = true;
}
}
}
return isInstalled;
}