
String install = versionKey.GetValue("Install "," ").ToString()

String sp = versionKey.GetValue("SP "," ").ToString() String name = (string)versionKey.GetValue("Version "," ") RegistryKey versionKey = ndpKey.OpenSubKey(versionKeyName) using (RegistryKey ndpKey = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine,įoreach (string versionKeyName in ndpKey.GetSubKeyNames()) As an alternative, if you know the computers you will query are running. Private static void GetVersionFromRegistry ( ) Return"No 4.5 or later version detected " Private static string CheckFor45DotVersion(int releaseKey)

the framework to ensure your app works the same. however you should always compile your code on newer versions of Checking the version using >= will enable forward compatibility, Int releaseKey = Convert.ToInt32(ndpKey.GetValue("Release ")) Ĭonsole.WriteLine("Version : " + CheckFor45DotVersion(releaseKey)) Private static void Get45or451FromRegistry ( )
