How to detect VC++ 2008 redistributable?

前端 未结 13 1961
借酒劲吻你
借酒劲吻你 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;
        }
    }
    

提交回复
热议问题