How to detect VC++ 2008 redistributable?

前端 未结 13 1965
借酒劲吻你
借酒劲吻你 2020-12-01 02:00

Is there a Registry setting that I can look for to determine whether or not the Visual C++ redistributable is installed, whether standalone or as part of Visual Studio 2008?

13条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 02:40

    I open-sourced a Visual C++ project on Github that checks for VC++ redistributable DLLs specifically and made it available under the Apache 2.0 license.

    It has three different methods for checking for the availability of VC++9 and VC++10 runtimes:

    1. Checks the MsiQueryProductState APIs;
    2. Inspect the contents of the WinSxS folder for matching product directories; and
    3. Checks the current working directory for any local versions of the VC++9 and VC++10 runtimes (and inspects their contents.)

    edit: Here's a sample of what using it actually looks like:

     wcout << _T("Checking for the availability of VC++ runtimes..") << endl;
     wcout << _T("----------- Visual C++ 2008 (VC++9) -----------") << endl;
     wcout << _T("Visual C++ 2008 (x86) ? ") << (IsVC2008Installed_x86() ? _T("true") : _T("false")) << endl;
     wcout << _T("Visual C++ 2008 (x64) ? ") << (IsVC2008Installed_x64() ? _T("true") : _T("false")) << endl;
     wcout << _T("Visual C++ 2008 SP1 (x86) ? ") << (IsVC2008SP1Installed_x86() ? _T("true") : _T("false")) << endl;
     wcout << _T("Visual C++ 2008 SP1 (x64) ? ") << (IsVC2008SP1Installed_x64() ? _T("true") : _T("false")) << endl;
    

    I licensed the crt-detector project under Apache 2.0, so feel free to use it in your own applications.

提交回复
热议问题