次の方法で共有


How do I detect what .NET Framework version is installed on a machine?

I see this question asked again and again on various newsgroups. After picking some of the BIG brains I work with here are two methods you may want to consider:

Method 1:

1.) Under HKLM\SOFTWARE\Microsoft\.NETFramework\policy\ check to see if the version you want is installed (for example, look for the v1.1 folder and 4322 for the version number to detect the released version of V1.1)

2.) Under HKLM\Software\Microsoft\.NETFramework\InstallRoot get the path where the Framework is installed. Create a directory string by concatenating the install root and the version under policy. E.g. "C:\WINDOWS\Microsoft.NET\Framework\" + "v1.1" + "." + "4322"

3.) Look at the directory, if mscorlib.dll (or another critical .dll to the .NET framework is there) the runtime is installed.

 

Method 2:

There's a caveat to this method in that the shim gets left behind when we uninstall if there is more than one version of the CLR on the machine, but it still can be useful depending on what version you're looking for:

LoadLibrary(“mscoree.dll“); - if this fails then there's no runtime installed

GetProcAddress(“CorBindToRuntime“); - if this fails there's no runtime installed

CorBindToRuntime(“GetRequestedRuntimeInfo“);

GetRequestedRuntimeInfo(xxxx); where xxxx is the build number.

 

This posting is provided "AS IS" with no warranties, and confers no rights.

Comments

  • Anonymous
    February 18, 2004
    Thanks Rob,

    It worked! My system modelling and probability now works!

    J.Lee
  • Anonymous
    April 12, 2004
    Cool!! Good trick, man!