How to detect VC++ 2008 redistributable?

前端 未结 13 1905
借酒劲吻你
借酒劲吻你 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:41

    Found registry entry for VC2008 redistributable. Here is my solution:

    BOOL IsVC2008RedistInstalled(LPCTSTR pLogFile)
    {
        TCHAR szLogEntry[256];
        memset(szLogEntry, '0', sizeof(szLogEntry));
        HKEY hKey;
        LONG lErr;
    
        TCHAR csid[256];
        _stprintf( csid, _T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{9A25302D-30C0-39D9-BD6F-21E6EC160475}"));
        lErr = RegOpenKeyEx(HKEY_LOCAL_MACHINE, csid, 0, KEY_QUERY_VALUE, &hKey);
        if (lErr == ERROR_SUCCESS)
        {
        _stprintf(szLogEntry, _T("VC2008 Redistributable was installed before.\n"));
        toFile(pLogFile, szLogEntry);
        return TRUE;
        }
        else
        {
        _stprintf(szLogEntry, _T("VC2008 Redistributable was not installed before. %ld\n"), lErr);
        toFile(pLogFile, szLogEntry);
        return FALSE;
        }
    }
    
    0 讨论(0)
  • 2020-12-01 02:47

    looks like there is another solution proposed by a Microsoft-Developer, using MsiQueryProductState API, alas also relying on the GUIDs.

    Update: The code went live yesterday and seems to be working fine. Here is what is beeing done: It is checked for the latest-known-to-me GUID AND the path² to-where-it-is-supposed-to-be-installed. If both fails, it is installed. This seems to work fine.

    Additionally, it is installed with the command line arguments "/qb" which means "unattended but not invisible". See this other blog post about those params.

    FWIW, GUIDs for Microsoft Visual C++ 2008 / VC90 SP1 Redistributable - x86 9.0.30729

    • 64bit 30729.17: 8220EEFE-38CD-377E-8595-13398D740ACE
    • 32bit 30729.17: 9A25302D-30C0-39D9-BD6F-21E6EC160475
    • 32bit 30729.01: 6AFCA4E1-9B78-3640-8F72-A7BF33448200

    ² The path: $WINDIR\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729*

    0 讨论(0)
  • 2020-12-01 02:48

    Check the registry:

    VC++2008 (sp1): HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3C3D696B-0DB7-3C6D-A356-3DB8CE541918}

    or

    VC++2008 (original): HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}

    0 讨论(0)
  • 2020-12-01 02:50

    Quick and dirty:

    if (LoadLibrary(L"msvcrt80.dll")!=NULL)
    {
      // it is installed
    }
    

    Loadlibrary will handle searching the paths for you.

    0 讨论(0)
  • 2020-12-01 02:55

    Latest one for VC2005:

    Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update

    * VC 8.0 SP1 MFCLOC Patch (x86) - {710F4C1C-CC18-4C49-8CBF-51240C89A1A2}
    * VC 8.0 SP1 MFCLOC Patch (x64) - {AD8A2FA1-06E7-4B0D-927D-6E54B3D31028}
    * VC 8.0 SP1 MFCLOC Patch (ia64) - {C2F60BDA-462A-4A72-8E4D-CA431A56E9EA}
    

    8.0.50727.6195

    http://www.microsoft.com/downloads/details.aspx?familyid=AE2E1A40-7B45-4FE9-A20F-2ED2923ACA62

    0 讨论(0)
  • 2020-12-01 02:56

    Product code for "Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC Security Update (x86)" is {9BE518E6-ECC6-35A9-88E4-87755C07200F}

    0 讨论(0)
提交回复
热议问题