我试图让我的应用程序确定用户系统上是否已安装 Microsoft Visual C++ 2013 Redistributable。我查看了答案here , here ,和 here ,但看起来所有答案都分为两大类:
- 检查注册表:这不是一个选项,因为如果安装了 Visual Studio 或删除了 Visual C++,您会收到误报。
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
就是这种情况。 ,HKLM\SOFTWARE\Microsoft\VisualStudio\12.0\VC
,和HKLM\SOFTWARE\Wow6432Node\Microsoft\DevDiv\VC
. - 使用 WMI/检查系统表使用
wmic product get
或new ManagementObjectSearcher("SELECT * FROM Win32_Product")
。这是可靠的,但非常慢(40 秒以上),因为它看起来必须在返回结果之前加载系统上安装的所有产品。
运行可再发行安装程序时,安装程序能够很快确定该组件是否已安装:
或者未安装:
最快且仍然可靠的方法是什么?理想情况下,我想知道:微软是如何做到如此快的?我可以这样做吗?
最佳答案
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/