通过MSI的API来查询 ,参见MSDN说明 MsiQueryProductState
MsiQueryProductState的输入参数为产品ID,其返回值为产品安装状态,若返回值为INSTALLSTATE_DEFAULT则表示已安装,以下为一些VC运行库产品ID:
Visual C++ 2005 runtime files
Visual C++ 2005 Redistributable Package (x86) - {A49F249F-0C91-497F-86DF-B2585E8E76B7}
Visual C++ 2005 Redistributable Package (x64) - {6E8E85E8-CE4B-4FF5-91F7-04999C9FAE6A}
Visual C++ 2005 Redistributable Package (ia64) - {03ED71EA-F531-4927-AABD-1C31BCE8E187}
Visual C++ 2005 SP1 runtime files
Visual C++ 2005 SP1 Redistributable Package (x86) - {7299052B-02A4-4627-81F2-1818DA5D550D}
Visual C++ 2005 SP1 Redistributable Package (x64) - {071C9B48-7C32-4621-A0AC-3F809523288F}
Visual C++ 2005 SP1 Redistributable Package (ia64) - {0F8FB34E-675E-42ED-850B-29D98C2ECE08}
Visual C++ 2005 SP1 ATL Security Update runtime files
Visual C++ 2005 SP1 ATL Security Update Redistributable Package (x86) - {837B34E3-7C30-493C-8F6A-2B0F04E2912C}
Visual C++ 2005 SP1 ATL Security Update Redistributable Package (x64) - {6CE5BAE9-D3CA-4B99-891A-1DC6C118A5FC}
Visual C++ 2005 SP1 ATL Security Update Redistributable Package (ia64) - {85025851-A784-46D8-950D-05CB3CA43A13}
Visual C++ 2008 runtime files
* VC 9.0 (x86) - {FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
* VC 9.0 (x64) - {350AA351-21FA-3270-8B7A-835434E766AD}
* VC 9.0 (ia64) - {2B547B43-DB50-3139-9EBE-37D419E0F5FA}
Visual C++ 2008 SP1 runtime files
* VC 9.0 SP1 (x86) - {9A25302D-30C0-39D9-BD6F-21E6EC160475}
* VC 9.0 SP1 (x64) - {8220EEFE-38CD-377E-8595-13398D740ACE}
* VC 9.0 SP1 (ia64) - {5827ECE1-AEB0-328E-B813-6FC68622C1F9}
Visual C++ 2008 SP1 ATL Security Update runtime files
* VC 9.0 SP1 ATL (x86) - {1F1C2DFC-2D24-3E06-BCB8-725134ADF989}
* VC 9.0 SP1 ATL (x64) - {4B6C7001-C7D6-3710-913E-5BC23FCE91E6}
* VC 9.0 SP1 ATL (ia64) - {977AD349-C2A8-39DD-9273-285C08987C7B}