【问题标题】:How to detect Visual C++ 2013 redistributable package如何检测 Visual C++ 2013 可再发行包
【发布时间】:2015-03-06 13:43:16
【问题描述】:

如何检测“Visual C++ 2013 redistributable”何时安装?

以下 c++ 代码正确检测到 2010 redist:

    // Visual C++ 2010 Redist detection...
    INSTALLSTATE state = pMsiProc( _T("{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}") );
    if(state == INSTALLSTATE_DEFAULT)
    {
        // Visual C++ 2010 redist installed.
    }

我希望对 2013 redist 使用相同类型的代码,但无论软件包是否安装,INSTALLSTATE 总是返回 INSTALLSTATE_DEFAULT。有人知道为什么吗?

    // call MsiQueryProductStateW...
    INSTALLSTATE state = pMsiProc(_T("{13A4EE12-23EA-3371-91EEEFB36DDFFF3E}"));
    // 
    if ((state == INSTALLSTATE_DEFAULT || state == INSTALLSTATE_LOCAL) 
    {
        // 2013 redist is installed.
    }

【问题讨论】:

    标签: c++ visual-studio-2013


    【解决方案1】:

    您使用的是 x86 架构吗?如果不是,代码不同:https://allthingsconfigmgr.wordpress.com/2013/12/17/visual-c-redistributables-made-simple/

    【讨论】:

      【解决方案2】:

      作为替代方案,您可以枚举注册表,查看“Displayname”键以获取以下标记:'Microsoft'、'Visual'、'C++'、'Redistributable'。您可以使用以下内容来确定子键是否是您所追求的...

      //  search for valid tokens to indicate this is a redistributable.
      resToken = name.Tokenize (_T(" "), curPos);
      while (resToken != _T(""))
          {
          if (resToken == _T("Microsoft"))
              tokenCount |= 0x01;
          if (resToken == _T("Visual"))
              tokenCount |= 0x02;
          if (resToken == _T("C++"))
              tokenCount |= 0x04;
          if (resToken == _T("Redistributable"))
              tokenCount |= 0x08;
          resToken = name.Tokenize (_T(" "), curPos);
          }
      
      //  check for matching tokens in the Display Name.
      if (tokenCount == 0x0f)
          {
      

      只需从“SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall”开始搜索,然后枚举上述值的所有子键。您还需要检查 32 位和 64 位配置单元。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-08-07
        • 2020-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多