CheckForDotNet45.Program.GetDotnetReleaseKeyFromRegistry C# (CSharp) Method

GetDotnetReleaseKeyFromRegistry() private static method

Gets the .Net release key from registry "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\".
private static GetDotnetReleaseKeyFromRegistry ( ) : int
return int
        private static int GetDotnetReleaseKeyFromRegistry()
        {
            int releaseKey = -1;

            // Based on http://msdn.microsoft.com/en-us/library/hh925568%28v=vs.110%29.aspx#net_d
            using (
                RegistryKey ndpKey =
                    RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32)
                        .OpenSubKey(@"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full\"))
            {
                if (ndpKey != null)
                {
                    object releaseKeyValue = ndpKey.GetValue("Release") ?? "-1";
                    int.TryParse(releaseKeyValue.ToString(), out releaseKey);
                }

                return releaseKey;
            }
        }