转载:http://blogs.msdn.com/b/astebner/archive/2009/01/29/9384143.aspx
Question:
I saw a couple of previous blog posts that you wrote about how to detect the presence of the Visual C++ 2005 runtime files and the Visual C++ 2005 SP1 runtime files. I am creating an installer that requires the Visual C++ 2008 runtime files. How can I detect the presence of the Visual C++ 2008 and 2008 SP1 runtime files?
Answer:
Like in the Visual C++ 2005 runtime files, there is not a specific detection mechanism designed and built into the Visual C++ 2008 runtime files installers. You can use an algorithm like the one I described in my previous blog posts to detect the presence of the Visual C++ 2008 runtime files products on a system:
- Call the MsiQueryProductState API
- Pass in the product code for the package that you want to detect based on the list below
- Check the return value of this API. If it is anything other than INSTALLSTATE_DEFAULT, the package is not yet installed
Visual C++ 2008 runtime files
- Visual C++ 2008 Redistributable Package (x86) - {FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
- Visual C++ 2008 Redistributable Package (x64) - {350AA351-21FA-3270-8B7A-835434E766AD}
- Visual C++ 2008 Redistributable Package (ia64) - {2B547B43-DB50-3139-9EBE-37D419E0F5FA}
Visual C++ 2008 SP1 runtime files
- Visual C++ 2008 SP1 Redistributable Package (x86) - {9A25302D-30C0-39D9-BD6F-21E6EC160475}
- Visual C++ 2008 SP1 Redistributable Package (x64) - {8220EEFE-38CD-377E-8595-13398D740ACE}
- Visual C++ 2008 SP1 Redistributable Package (ia64) - {5827ECE1-AEB0-328E-B813-6FC68622C1F9}
Visual C++ 2008 SP1 ATL Security Update runtime files
- Visual C++ 2008 SP1 ATL Security Update Redistributable Package (x86) - {1F1C2DFC-2D24-3E06-BCB8-725134ADF989}
- Visual C++ 2008 SP1 ATL Security Update Redistributable Package (x64) - {4B6C7001-C7D6-3710-913E-5BC23FCE91E6}
- Visual C++ 2008 SP1 ATL Security Update Redistributable Package (ia64) - {977AD349-C2A8-39DD-9273-285C08987C7B}
Visual C++ 2008 SP1 MFC Security Update runtime files
- Visual C++ 2008 SP1 MFC Security Update Redistributable Package (x86) - {9BE518E6-ECC6-35A9-88E4-87755C07200F}
- Visual C++ 2008 SP1 MFC Security Update Redistributable Package (x64) - {5FCE6D76-F5DC-37AB-B2B8-22AB8CEDB1D4}
- Visual C++ 2008 SP1 MFC Security Update Redistributable Package (ia64) - {515643D1-4E9E-342F-A75A-D1F16448DC04}
<update date="11/19/2009"> Added information about the Visual C++ 2008 SP1 ATL Security Update product codes. </update>
<update date="11/7/2011"> Added information about the Visual C++ 2008 SP1 MFC Security Update product codes. </update>