c# - 如何快速而可靠地确定是否安装了 Visual C++ 2013 Runtime

标签 c# .net windows

我试图让我的应用程序确定用户系统上是否已安装 Microsoft Visual C++ 2013 Redistributable。我查看了答案here , here ,和 here ,但看起来所有答案都分为两大类:

  1. 检查注册表:这不是一个选项,因为如果安装了 Visual Studio 或删除了 Visual C++,您会收到误报。 HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall 就是这种情况。 , HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\VC ,和HKLM\SOFTWARE\Wow6432Node\Microsoft\DevDiv\VC .
  2. 使用 WMI/检查系统表使用 wmic product getnew ManagementObjectSearcher("SELECT * FROM Win32_Product") 。这是可靠的,但非常慢(40 秒以上),因为它看起来必须在返回结果之前加载系统上安装的所有产品。

运行可再发行安装程序时,安装程​​序能够很快确定该组件是否已安装:

Already installed

或者未安装:

Not installed

最快且仍然可靠的方法是什么?理想情况下,我想知道:微软是如何做到如此快的?我可以这样做吗?

最佳答案

As has now been explained in the answer to another question ,还有更可靠的注册表值可以使用:

Microsoft Visual C++ 2013 Redistributable (x64)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{050d4fc8-5d48-4b8f-8972-47c82c46020f} 
Configuration: x64
Version: 12.0.30501.0

Microsoft Visual C++ 2013 Redistributable (x86)
Registry Key: HKLM\SOFTWARE\Classes\Installer\Dependencies\{f65db027-aff3-4070-886a-0d87064aabb1} 
Configuration: x86
Version: 12.0.30501.0

关于c# - 如何快速而可靠地确定是否安装了 Visual C++ 2013 Runtime,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34168888/

相关文章:

c# - 如何自定义WPF Ribbon 4.5(样式、模板等)

c# - 适用于 Android/Java 和 .Net 的 AES 加密仅部分相同

c# - 为什么我的 Interop 代码会抛出 "Stack cookie instrumentation code detected a stack-based buffer overrun"异常?

c# - 调用JSON web服务时如何获取异常信息

c# - 如何使 Roslyn Analyzer 项目成为可传递依赖项?

java - 分布式事务 .net java SAP

c++ - 英特尔 tbb 中的奇怪错误

c# - 转换 : Unable to cast object of type 'System.DBNull' to type 'System.String'

windows - Android Studio 上的 Inconsolata 字体

python - 尽管是文件的所有者,但 READ_CONTROL 的 CreateFileW 失败并显示 "Access is denied"