Detect .NET Framework Version Programmatically

If you need to determine what versions of the .NET Framework are available on a machine programmatically, you’d ideally use a C++ program (since it has no dependencies on .NET).  But if you can guarantee that .NET 2.0 will be available, there’s another option.  The source code (written by Scott Dorman) is ported from a C++ program.  I’m using the library for an application launcher that verifies the right version of the .NET Framework is available (among other prerequisites).