1
<html><head><META HTTP-EQUIV=
"Content-Type" CONTENT=
"text/html; CHARSET=utf-8" /><META NAME=
"save" CONTENT=
"history" /><title xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">CLR Version Detection Technology Sample
</title><META NAME=
"Description" CONTENT=
"
 This sample shows how to detect which versions of the .NET Framework common language runtime (CLR) are installed on a computer.
 "></META><META NAME=
"MS.LOCALE" CONTENT=
"en-us" /><style>
3 {font-family:Verdana;font-size:medium;}
4 div#mainSection, div#header
5 {font-size:
70%;width:
100%;}
8 div#mainSection div table
9 {font-size:
100%;text-align: left;}
11 {color:#
003399;font-size:
90%;font-weight:
600;}
13 {background-color:#D4DFFF;}
15 {font-size:
120%;color:#
003399;}
17 {font-size:
100%;margin-bottom:
4;}
19 {margin-top:-
2;margin-bottom:
3;}
21 {margin-top:
10;margin-bottom:
5;}
23 {margin-top:
1;margin-bottom:
4;}
24 div#mainSection table th
25 {background-color:#EFEFF7;color:#
000066;text-align:left;}
26 div#mainSection table td
27 {background-color:#F7F7FF;}
29 {margin-top:
5px;margin-bottom: px;}
30 </style></head><body><div id=
"header"><table width=
"100%" id=
"topTable"></table></div><div id=
"mainSection"><div id=
"mainBody"><br /><font color=
"DarkGray">[This readme is a partial copy of the sample's topic in the SDK documentation.]
</font><br /><font color=
"DarkGray" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"></font><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"></p><div class=
"introduction"><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
31 This sample shows how to detect which versions of the .NET Framework common language runtime (CLR) are installed on a computer.
32 </p><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
33 For information about using the samples, see the following topics:
34 </p><ul xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><li><p><span sdata=
"link">How to: View and Download Samples
</span></p></li><li><p><span sdata=
"link">How to: Set Sample Settings
</span></p></li></ul></div><h3 class=
"procedureSubHeading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">To build the sample using Visual Studio
</h3><div class=
"subSection"><ol xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><li><p>
35 Open Windows Explorer and navigate to the CP subdirectory under the CLRVerSample directory.
37 Double-click the icon for CLRVerCP.sln to open it in Visual Studio
2005.
39 On the
<span class=
"ui">Build
</span> menu, click
<span class=
"ui">Build Solution
</span>.
40 </p></li></ol></div><h3 class=
"procedureSubHeading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">To run the sample
</h3><div class=
"subSection"><ol xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><li><p>
41 In the Command Prompt window, navigate to the directory that contains the new executable.
43 Type
<span class=
"input">CLRVer.exe
</span> at the command line.
44 </p></li></ol></div><h1 class=
"heading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><span onclick=
"ExpandCollapse(requirementsTitleToggle)" style=
"cursor:default;" onkeypress=
"ExpandCollapse_CheckKey(requirementsTitleToggle, event)" tabindex=
"0">Requirements
</span></h1><div id=
"requirementsTitleSection" class=
"section"><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><span class=
"label">.NET Framework Version:
</span> 2.0,
1.1
45 </p><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
46 Microsoft Visual Studio
2005
47 </p><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
48 These samples require Windows headers which are available to your project if you build using Microsoft Visual Studio
2005, the
<span class=
"ui">Visual Studio
2005 Command Prompt
</span>, or if you have the Platform SDK installed and specified in an include path.
49 </p></div><h1 class=
"heading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><span onclick=
"ExpandCollapse(sectionToggle0)" style=
"cursor:default;" onkeypress=
"ExpandCollapse_CheckKey(sectionToggle0, event)" tabindex=
"0">Remarks
</span></h1><div id=
"sectionSection0" class=
"section"><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
50 This sample is available only in C++. The sample code calls unmanaged APIs that are defined in mscoree.h, which is included in the \include subdirectory under your Windows Software Development Kit (SDK) installation directory, to list the versions of the CLR that are installed on the local computer.
51 </p><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
52 This sample calls the unmanaged
<span sdata=
"link">GetRequestedRuntimeInfo Function
</span> method, which returns information about the CLR version loaded into the process. This information does not always show the latest CLR version installed on the computer.
53 </p><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
54 In the .NET Framework version
2.0, you can get the latest installed CLR version by specifying the following for the
<span sdata=
"link">GetRequestedRuntimeInfo Function
</span> parameters:
55 </p><ul xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><li><p>
56 The first three parameters as
<span sdata=
"langKeyword" value=
"null"><span class=
"keyword">null
</span></span>.
58 The RUNTIME_INFO_UPGRADE_VERSION flag in the
<span sdata=
"link">RUNTIME_INFO_FLAGS Enumeration
</span> enumerations specified for the
<span class=
"parameter" sdata=
"paramReference">runtimeInfoFlags
</span> parameter.
59 </p></li></ul><p xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">
60 The
<span sdata=
"link">GetRequestedRuntimeInfo Function
</span> method may not return the latest CLR version in the following circumstances:
61 </p><ul xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><li><p>
62 If an application configuration file exists that specifies loading a particular CLR version. Note that the .NET Framework will use the configuration file even if
<span sdata=
"langKeyword" value=
"null"><span class=
"keyword">null
</span></span> is specified for
<span class=
"parameter" sdata=
"paramReference">pConfigurationFile
</span> parameter.
64 If
<span sdata=
"link">CorBindToRuntimeEx Function
</span> was called specifying an earlier CLR version.
66 If an application is currently running that was compiled for an earlier CLR version.
67 </p></li></ul></div><h1 class=
"heading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt"><span onclick=
"ExpandCollapse(seeAlsoToggle)" style=
"cursor:default;" onkeypress=
"ExpandCollapse_CheckKey(seeAlsoToggle, event)" tabindex=
"0">See Also
</span></h1><div id=
"seeAlsoSection" class=
"section"><h4 class=
"subHeading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">Concepts
</h4><div class=
"seeAlsoStyle"><span sdata=
"link" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">Runtime Hosts
</span></div><h4 class=
"subHeading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">Reference
</h4><div class=
"seeAlsoStyle"><span sdata=
"link" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">GetCORVersion Function
</span></div><h4 class=
"subHeading" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">Other Resources
</h4><div class=
"seeAlsoStyle"><span sdata=
"link" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">Hosting the Common Language Runtime
</span></div><div class=
"seeAlsoStyle"><span sdata=
"link" xmlns:
mshelp=
"http://msdn.microsoft.com/mshelp" xmlns:
msxsl=
"urn:schemas-microsoft-com:xslt">Unmanaged API Reference
</span></div></div></div></div></body></html>