1 // Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
2 
3 using System;
4 using Microsoft.Win32;
5 
6 namespace Microsoft.TestCommon
7 {
8     public static class RuntimeEnvironment
9     {
10         private const string NetFx40FullSubKey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full";
11         private const string Version = "Version";
12 
RuntimeEnvironment()13         static RuntimeEnvironment()
14         {
15             object runtimeVersion = Registry.LocalMachine.OpenSubKey(RuntimeEnvironment.NetFx40FullSubKey).GetValue(RuntimeEnvironment.Version);
16             string versionFor40String = runtimeVersion as string;
17             if (versionFor40String != null)
18             {
19                 VersionFor40 = new Version(versionFor40String);
20             }
21         }
22 
23         private static Version VersionFor40;
24 
25         public static bool IsVersion45Installed
26         {
27             get
28             {
29                 return VersionFor40.Major > 4 || (VersionFor40.Major == 4 && VersionFor40.Minor >= 5);
30             }
31         }
32     }
33 }
34