Mailbag: How to detect the presence of the Visual C++ 2010 redistributable package

Question:

I have seen your previous blog posts that describe how to detect the presence of the Visual C++ 2005 redistributable package and the Visual C++ 2008 redistributable package.  I am creating an installer that requires the Visual C++ 2010 runtime files.  How can I detect the presence of the Visual C++ 2010 redistributable package?

Answer:

Unlike the Visual C++ 2005 and 2008 redistributable packages, there are registry keys that can be used to detect the presence of the Visual C++ 2010 redistributable package.

Visual C++ 2010 redistributable package detection registry values

Alternatively, like in past releases of the Visual C++ redistributable package, you can use an algorithm like the one I described in my previous blog posts to detect the presence of the Visual C++ 2010 redistributable package on a system:

  1. Call the MsiQueryProductState API
  2. Pass in the product code for the package that you want to detect based on the list below
  3. Check the return value of this API.  If it is anything other than INSTALLSTATE_DEFAULT, the package is not yet installed

Visual C++ 2010 redistributable package product codes

Visual C++ 2010 SP1 redistributable package product codes

<update date="4/12/2011"> Added product codes for Visual C++ 2010 SP1 redistributable packages. </update>