如何检测是否需要安装VCRedist?

发布于 2024-07-16 09:31:55 字数 668 浏览 11 评论 0 原文

我有一个与这个问题非常相似的问题,但答案不适用于我。

我维护安装的软件依赖于 VC++ 2008(准确地说是 SP1),因此我需要找到一个解决方案来安装 VCRedist(如果尚未安装)。 我知道正确的方法是使用合并模块构建 msi,但它不在我手中。

我提到的重复问题的答案(已接受的问题)对我不起作用,因为每个小版本(例如 9.0.30729.01 与 9.0.30729.17)都有正确的 GUID,我无法猜测或预测未来的版本。 此外,我认为这不会检测到 Visual Studio,因此当 VCRedist 包已经在开发人员计算机上时,就不需要安装它。 我不想用这个来打扰任何人,当然不是已经安装了 DevStudio 的人。

现在另一个答案说我应该查看 WinSxs 文件夹,例如 $WINDIR\WinSxS\x86_Microsoft.VC80.CRT_ 但这并不能(还)帮助我暗示 SP1,或者我缺少什么在此刻 ? 是否有一个包含内部和“外部”版本号的表格,以便我可以暗示某个次要版本号?

我不敢相信微软没有为这种情况提供任何东西,但是在互联网上搜索已经太久了,现在让我回到了好的ol'SO:)

I have a question very similar to this one but the answer does not work for me.

Software I am maintaining the setup for depends on VC++ 2008 (SP1, precisely), thus I need to find a solution to install VCRedist if not yet installed.
I understand the correct way would be to build msi with merge modules, but it's not on my hands.

The answer of the duplicate question I am referring to (the accepted one) does not work for me because every tiny release (e.g. 9.0.30729.01 vs 9.0.30729.17) has proper GUIDs, which I am not able to guess or predict for future versions. Furthermore, I reckon that this would not detect Visual Studios and thus unnecessarily install the VCRedist Package when it's already on a developers machine. I do not want to bug anybody with this, certainly not somebody who has already a DevStudio installed.

Now another answer says I should look in the WinSxs-folder like $WINDIR\WinSxS\x86_Microsoft.VC80.CRT_ but this does not (yet) help me to imply SP1, or is there anything I am missing at this point ? Is there a table somewhere with the internal and "external" version numbers, so I could imply a certain minor version number ?

I cannot believe that there is nothing provided by Microsoft for this scenario, but searching the interwebs for already far too long now brings me back to good ol' SO :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

む无字情书 2024-07-23 09:31:55

对于 Visual Studio C++ 2010,事情变得更容易了

与 Visual C++ 2005 和 2008 可再发行软件包不同,有一些注册表项可用于检测 Visual C++ 2010 可再发行软件包是否存在。

Visual C++ 2010 可再发行包检测注册表值

Visual C++ 2010 可再发行组件包 (x86)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86]
已安装 = 1 (REG_DWORD)

Visual C++ 2010 可再发行组件包 (x64)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64]
已安装 = 1 (REG_DWORD)

Visual C++ 2010 可再发行组件包 (ia64)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\ia64]
已安装 = 1 (REG_DWORD)

注意:您需要在 64 位操作系统上检查 Wow6432Node。 (HKLM\Software\Wow6432Node\Microsoft...)

如果您喜欢旧版本,这里是 GUID

Visual C++ 2010 可再发行软件包产品代码

  • Visual C++ 2010 可再发行软件包 (x86) - {196BB40D-1578-3D01-B289-BEFC77A11A1E }
  • Visual C++ 2010 可再发行软件包 (x64) - {DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}
  • Visual C++ 2010 可再发行软件包 (ia64) - {C1A35166-4301-38E9-BA67-02823AD72A1B}

Visual C++ 2010 SP1贡献包产品代码

  • 视觉C++ 2010 SP1 可再发行软件包 (x86) - {F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
  • Visual C++ 2010 SP1 可再发行软件包 (x64) - {1D8E6291-B0D5-35EC-8441-6616F567A0F7} Visual C++ 2010 SP1可分
  • 发包 (ia64) - {88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}

For Visual Studio C++ 2010, things got a bit easier.

Unlike the Visual C++ 2005 and 2008 redistributable packages, there are registry keys that can be used to detect the presence of the Visual C++ 2010 redistributable package.

Visual C++ 2010 redistributable package detection registry values

Visual C++ 2010 Redistributable Package (x86)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x86]
Installed = 1 (REG_DWORD)

Visual C++ 2010 Redistributable Package (x64)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\x64]
Installed = 1 (REG_DWORD)

Visual C++ 2010 Redistributable Package (ia64)

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\10.0\VC\VCRedist\ia64]
Installed = 1 (REG_DWORD)

Note: You will need to check under Wow6432Node on a 64-bit OS. (HKLM\Software\Wow6432Node\Microsoft....)

If you like the older version, here are the GUIDs

Visual C++ 2010 redistributable package product codes

  • Visual C++ 2010 Redistributable Package (x86) - {196BB40D-1578-3D01-B289-BEFC77A11A1E}
  • Visual C++ 2010 Redistributable Package (x64) - {DA5E371C-6333-3D8A-93A4-6FD5B20BCC6E}
  • Visual C++ 2010 Redistributable Package (ia64) - {C1A35166-4301-38E9-BA67-02823AD72A1B}

Visual C++ 2010 SP1 redistributable package product codes

  • Visual C++ 2010 SP1 Redistributable Package (x86) - {F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}
  • Visual C++ 2010 SP1 Redistributable Package (x64) - {1D8E6291-B0D5-35EC-8441-6616F567A0F7}
  • Visual C++ 2010 SP1 Redistributable Package (ia64) - {88C73C1C-2DE5-3B01-AFB8-B46EF4AB41CD}
半岛未凉 2024-07-23 09:31:55

您可以采用推荐的方法来安装 directx:始终运行可再发行组件。 由于它是必需的并且您已经交付了它,因此即使它已经安装,运行它也没有什么坏处。

You could take the recommended approach for installing directx: always run the redistributable. Since it's required and you're already shipping it there's no harm in running it even if it's already installed.

棒棒糖 2024-07-23 09:31:55

看起来微软提出了另一种解决方案 -开发人员,使用 MsiQueryProductState API,可惜还依赖于 GUID。

更新:代码昨天上线,看起来运行良好。 这是正在做的事情:检查我已知的最新 GUID 和应该安装的路径²。 如果两者都失败,则已安装。 这似乎工作正常。

此外,它是通过命令行参数“/qb”安装的,这意味着“无人值守但并非不可见”。 有关这些参数的信息,请参阅另一篇博客文章

FWIW,Microsoft Visual C++ 2008 / VC90 SP1 可再发行组件的 GUID - x86 9.0.30729

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

² 路径:
$WINDIR\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729*

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*

夏末染殇 2024-07-23 09:31:55

我在 Github 上开源了 一个专门检查 VC++ 可再发行 DLL 的 Visual C++ 项目,并制作了它可以在 Apache 2.0 许可证下使用。

它具有三种不同的方法来检查 VC++9 和 VC++10 运行时的可用性:

  1. 检查 MsiQueryProductState API;
  2. 检查 WinSxS 文件夹的内容是否有匹配的产品目录; 并
  3. 检查当前工作目录中是否有任何本地版本的 VC++9 和 VC++10 运行时(并检查其内容。)

以下是实际使用情况的示例:

 wcout << _T("Checking for the availability of VC++ runtimes..") << endl;
 wcout << _T("----------- Visual C++ 2008 (VC++9) -----------") << endl;
 wcout << _T("Visual C++ 2008 (x86) ? ") << (IsVC2008Installed_x86() ? _T("true") : _T("false")) << endl;
 wcout << _T("Visual C++ 2008 (x64) ? ") << (IsVC2008Installed_x64() ? _T("true") : _T("false")) << endl;
 wcout << _T("Visual C++ 2008 SP1 (x86) ? ") << (IsVC2008SP1Installed_x86() ? _T("true") : _T("false")) << endl;
 wcout << _T("Visual C++ 2008 SP1 (x64) ? ") << (IsVC2008SP1Installed_x64() ? _T("true") : _T("false")) << endl;

我许可了 crt- detector Apache 2.0 下的项目,因此请随意在您自己的应用程序中使用它。

I open-sourced a Visual C++ project on Github that checks for VC++ redistributable DLLs specifically and made it available under the Apache 2.0 license.

It has three different methods for checking for the availability of VC++9 and VC++10 runtimes:

  1. Checks the MsiQueryProductState APIs;
  2. Inspect the contents of the WinSxS folder for matching product directories; and
  3. Checks the current working directory for any local versions of the VC++9 and VC++10 runtimes (and inspects their contents.)

Here's a sample of what using it actually looks like:

 wcout << _T("Checking for the availability of VC++ runtimes..") << endl;
 wcout << _T("----------- Visual C++ 2008 (VC++9) -----------") << endl;
 wcout << _T("Visual C++ 2008 (x86) ? ") << (IsVC2008Installed_x86() ? _T("true") : _T("false")) << endl;
 wcout << _T("Visual C++ 2008 (x64) ? ") << (IsVC2008Installed_x64() ? _T("true") : _T("false")) << endl;
 wcout << _T("Visual C++ 2008 SP1 (x86) ? ") << (IsVC2008SP1Installed_x86() ? _T("true") : _T("false")) << endl;
 wcout << _T("Visual C++ 2008 SP1 (x64) ? ") << (IsVC2008SP1Installed_x64() ? _T("true") : _T("false")) << endl;

I licensed the crt-detector project under Apache 2.0, so feel free to use it in your own applications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文