如何检测 VC++ 2008 年可再发行吗?

发布于 2024-07-07 10:57:18 字数 279 浏览 7 评论 0原文

我可以查找注册表设置来确定是否安装了 Visual C++ 可再发行组件(无论是独立安装还是作为 Visual Studio 2008 的一部分)? 我知道我可以启动 VC++ 2008 可再发行安装程序并让它处理检测,但如果我可以检查它并且在可再发行组件已在系统上时不必启动安装程序,那么看起来会更干净。

如果没有要搜索的设置也没什么大不了的,因为这只是我们新版本软件的初步安装程序。 我们正在开发的基于 Windows Installer 的新安装程序将不需要它,该安装程序将取代旧的技术安装程序并使用合并模块。

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? I know that I could launch the VC++ 2008 redistributable installer and let it handle the detection, but it would look cleaner if I can check for it and not bother launching the installer if the redistributable is already on the system.

It's no biggie if there is no setting to search for, as this is just for the preliminary installers that we have for the new version of our software. We won't need it for the new Windows Installer-based installers that we are working on that will replace the old tech ones and will use the merge modules.

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

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

发布评论

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

评论(13

乖乖 2024-07-14 10:57:18

当您使用不同的操作系统时,我认为这些解决方案都没有帮助! 例如,使用 Vista VC8.0 时,MsiQueryProductState 将始终返回 -1,

而对于使用 Windows 7 的 VC8.0/8.0 SP1/9.0,则始终返回 -1! 因此,微软提供的 GUID 解决方案并不适用于所有情况,

所以我想我被迫坚持使用 %windir%\winsxs 方法并搜索

  • x86_Microsoft.VC80.CRT*
  • x86_Microsoft.VC90.CRT*

对于那些正在寻找所有 GUID 的人,这里是我创建的列表:

Visual C++ 2005 运行时文件

* VC 8.0 (x86) - {A49F249F-0C91-497F-86DF-B2585E8E76B7}
* VC 8.0 (x64) - {6E8E85E8-CE4B-4FF5-91F7-04999C9FAE6A}
* VC 8.0 (ia64) - {03ED71EA-F531-4927-AABD-1C31BCE8E187}

Visual C++ 2005 SP1 运行时文件

* VC 8.0 SP1 (x86) - {7299052B-02A4-4627-81F2-1818DA5D550D}
* VC 8.0 SP1 (x64) - {071C9B48-7C32-4621-A0AC-3F809523288F}
* VC 8.0 SP1 (ia64) - {0F8FB34E-675E-42ED-850B-29D98C2ECE08}

Visual C++ 2005 SP1 ATL 安全更新运行时文件

* VC 8.0 SP1 ATL Patch (x86) - {837B34E3-7C30-493C-8F6A-2B0F04E2912C}
* VC 8.0 SP1 ATL Patch (x64) - {6CE5BAE9-D3CA-4B99-891A-1DC6C118A5FC}
* VC 8.0 SP1 ATL Patch (ia64) - {85025851-A784-46D8-950D-05CB3CA43A13}

Visual C++ 2008 运行时文件

* VC 9.0 (x86) - {FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
* VC 9.0 (x64) - {350AA351-21FA-3270-8B7A-835434E766AD}
* VC 9.0 (ia64) - {2B547B43-DB50-3139-9EBE-37D419E0F5FA} 

Visual C++ 2008 SP1 运行时文件

* VC 9.0 SP1 (x86) - {9A25302D-30C0-39D9-BD6F-21E6EC160475}
* VC 9.0 SP1 (x64) - {8220EEFE-38CD-377E-8595-13398D740ACE}
* VC 9.0 SP1 (ia64) - {5827ECE1-AEB0-328E-B813-6FC68622C1F9}

Visual C++ 2008 SP1 ATL 安全更新运行时文件

* VC 9.0 SP1 ATL (x86) - {1F1C2DFC-2D24-3E06-BCB8-725134ADF989}
* VC 9.0 SP1 ATL (x64) - {4B6C7001-C7D6-3710-913E-5BC23FCE91E6}
* VC 9.0 SP1 ATL (ia64) - {977AD349-C2A8-39DD-9273-285C08987C7B}

I don't think any of those solution can help when your using different OS ! For ex, MsiQueryProductState will always returned -1 using Vista VC8.0

while -1 for VC8.0/8.0 SP1/9.0 with Windows 7 ! So the GUID solution that microsoft provided, doesn't work in all cases

so i guess i'm forced to stuck with the %windir%\winsxs approach and search for

  • x86_Microsoft.VC80.CRT*
  • x86_Microsoft.VC90.CRT*

For those who are looking for all GUIDs, Here is a list i created:

Visual C++ 2005 runtime files

* VC 8.0 (x86) - {A49F249F-0C91-497F-86DF-B2585E8E76B7}
* VC 8.0 (x64) - {6E8E85E8-CE4B-4FF5-91F7-04999C9FAE6A}
* VC 8.0 (ia64) - {03ED71EA-F531-4927-AABD-1C31BCE8E187}

Visual C++ 2005 SP1 runtime files

* VC 8.0 SP1 (x86) - {7299052B-02A4-4627-81F2-1818DA5D550D}
* VC 8.0 SP1 (x64) - {071C9B48-7C32-4621-A0AC-3F809523288F}
* VC 8.0 SP1 (ia64) - {0F8FB34E-675E-42ED-850B-29D98C2ECE08}

Visual C++ 2005 SP1 ATL Security Update runtime files

* VC 8.0 SP1 ATL Patch (x86) - {837B34E3-7C30-493C-8F6A-2B0F04E2912C}
* VC 8.0 SP1 ATL Patch (x64) - {6CE5BAE9-D3CA-4B99-891A-1DC6C118A5FC}
* VC 8.0 SP1 ATL Patch (ia64) - {85025851-A784-46D8-950D-05CB3CA43A13}

Visual C++ 2008 runtime files

* VC 9.0 (x86) - {FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
* VC 9.0 (x64) - {350AA351-21FA-3270-8B7A-835434E766AD}
* VC 9.0 (ia64) - {2B547B43-DB50-3139-9EBE-37D419E0F5FA} 

Visual C++ 2008 SP1 runtime files

* VC 9.0 SP1 (x86) - {9A25302D-30C0-39D9-BD6F-21E6EC160475}
* VC 9.0 SP1 (x64) - {8220EEFE-38CD-377E-8595-13398D740ACE}
* VC 9.0 SP1 (ia64) - {5827ECE1-AEB0-328E-B813-6FC68622C1F9}

Visual C++ 2008 SP1 ATL Security Update runtime files

* VC 9.0 SP1 ATL (x86) - {1F1C2DFC-2D24-3E06-BCB8-725134ADF989}
* VC 9.0 SP1 ATL (x64) - {4B6C7001-C7D6-3710-913E-5BC23FCE91E6}
* VC 9.0 SP1 ATL (ia64) - {977AD349-C2A8-39DD-9273-285C08987C7B}
关于从前 2024-07-14 10:57:18

检查注册表:

VC++2008(sp1):
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3C3D696B-0DB7-3C6D-A356-3DB8CE541918}

VC++2008(原版):
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}

Check the registry:

VC++2008 (sp1):
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{3C3D696B-0DB7-3C6D-A356-3DB8CE541918}

or

VC++2008 (original):
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}

一江春梦 2024-07-14 10:57:18

VC2005 的最新版本:

Visual C++ 2005 Service Pack 1 Redistributable Package MFC 安全更新

* VC 8.0 SP1 MFCLOC Patch (x86) - {710F4C1C-CC18-4C49-8CBF-51240C89A1A2}
* VC 8.0 SP1 MFCLOC Patch (x64) - {AD8A2FA1-06E7-4B0D-927D-6E54B3D31028}
* VC 8.0 SP1 MFCLOC Patch (ia64) - {C2F60BDA-462A-4A72-8E4D-CA431A56E9EA}

8.0.50727.6195

http://www.microsoft.com/downloads/details.aspx?familyid=AE2E1A40-7B45-4FE9-A20F-2ED2923ACA62

Latest one for VC2005:

Visual C++ 2005 Service Pack 1 Redistributable Package MFC Security Update

* VC 8.0 SP1 MFCLOC Patch (x86) - {710F4C1C-CC18-4C49-8CBF-51240C89A1A2}
* VC 8.0 SP1 MFCLOC Patch (x64) - {AD8A2FA1-06E7-4B0D-927D-6E54B3D31028}
* VC 8.0 SP1 MFCLOC Patch (ia64) - {C2F60BDA-462A-4A72-8E4D-CA431A56E9EA}

8.0.50727.6195

http://www.microsoft.com/downloads/details.aspx?familyid=AE2E1A40-7B45-4FE9-A20F-2ED2923ACA62

烟花易冷人易散 2024-07-14 10:57:18

快速而肮脏:

if (LoadLibrary(L"msvcrt80.dll")!=NULL)
{
  // it is installed
}

Loadlibrary 将为您搜索路径。

Quick and dirty:

if (LoadLibrary(L"msvcrt80.dll")!=NULL)
{
  // it is installed
}

Loadlibrary will handle searching the paths for you.

ペ泪落弦音 2024-07-14 10:57:18

看起来微软提出了另一种解决方案 -开发人员,使用 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-14 10:57:18

例如,如果您要检查 Visual Studio 2008 可再发行组件,请检查 $WINDIR\WinSxS\x86_Microsoft.VC90.CRT_*

Check for $WINDIR\WinSxS\x86_Microsoft.VC90.CRT_* if, for example, you're checking for the Visual Studio 2008 redistributable.

情话墙 2024-07-14 10:57:18

我在 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.)

edit: 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.

入画浅相思 2024-07-14 10:57:18

为遇到此问题的其他人进行更新

1) 如果您安装了 Visual Studio,则所需的 DLL 将存在,但“redist 包”不存在,因此注册表项丢失。 (即这将给出假阴性)。 然而,在这种情况下,在顶部安装 redist 是无害的。

2) redist 的每个主要版本(VS2005/VS2008、x86/x64/IA64 和服务包:SP1、ATL 安全更新的任意组合)都有不同的 GUID。 如果您希望在 x86 和 x64 PC 上部署应用程序,请务必小心。

3) 如果您使用 LoadLibrary 或检查 Dll 文件,请确保您的目标版本正确。 如果您查找 msvcrt80.dll(等)的“任何”副本,那么您将无法判断它是否是您的程序链接到的版本。

Update for anyone else hitting this problem:

1) If you have Visual Studio installed, the required DLLs will be present, but the "redist package" is not, so the registry keys are missing. (i.e. this will give a false negative). However, installing the redist over the top in this situation is harmless.

2) Every major release of the redist (Any combination of VS2005/VS2008, x86/x64/IA64, and service packs: SP1,ATL security update) has a different GUID. Take care if you are expecting to deploy your application on both x86 and x64 PCs.

3) If you use LoadLibrary or a check for Dll files, make sure you target the correct version. If you look for "any" copy of msvcrt80.dll (etc) then you won't be able to tell if it is the version your program was linked to.

岁吢 2024-07-14 10:57:18

“Microsoft Visual C++ 2008 Service Pack 1 可再发行软件包 MFC 安全更新 (x86)”的产品代码为 {9BE518E6-ECC6-35A9-88E4-87755C07200F}

Product code for "Microsoft Visual C++ 2008 Service Pack 1 Redistributable Package MFC Security Update (x86)" is {9BE518E6-ECC6-35A9-88E4-87755C07200F}

笑红尘 2024-07-14 10:57:18

您可以检查 WINDOWS\WinSxS 目录下的文件来查看您安装的版本。 通常可以一次安装多个版本,因此您可能需要检查已安装的特定版本。

You can check for the files under the WINDOWS\WinSxS directory to see which versions you have installed. Often many versions can be installed at one time so you might need to check the specific versions you have installed.

不必了 2024-07-14 10:57:18

我想使用以下值扩展 GUID 列表:

32 位 30729.17
{9A25302D-30C0-39D9-BD6F-21E6EC160475}
32位30729.01
{6AFCA4E1-9B78-3640-8F72-A7BF33448200}
64位30729.17
{8220EEFE-38CD-377E-8595-13398D740ACE}
64位30729.01
{0DF3AE91-E533-3960-8516-B23737F8B7A2}
VC++2008(sp1)
{3C3D696B-0DB7-3C6D-A356-3DB8CE541918}
VC++2008(原创)
{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
IA64 30729.01
{22E23C71-C27A-3F30-8849-BB6129E50679}
32位30729.4148
{7B33F480-496D-334A-BAC2-205DEC0CBC2D}
Visual Studio 2008 专业 SP1
{D7DAD1E4-45F4-3B2B-899A-EA728167EC4F}
32位30729.01
{F333A33D-125C-32A2-8DCE-5C5D14231E27}

因此,请决定通过 GUID 检查 VCredist 是否存在是否是个好主意。

I'd like to extend the GUID list with the following values:

32bit 30729.17
{9A25302D-30C0-39D9-BD6F-21E6EC160475}
32bit 30729.01
{6AFCA4E1-9B78-3640-8F72-A7BF33448200}
64bit 30729.17
{8220EEFE-38CD-377E-8595-13398D740ACE}
64bit 30729.01
{0DF3AE91-E533-3960-8516-B23737F8B7A2}
VC++2008 (sp1)
{3C3D696B-0DB7-3C6D-A356-3DB8CE541918}
VC++2008 (original)
{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}
IA64 30729.01
{22E23C71-C27A-3F30-8849-BB6129E50679}
32bit 30729.4148
{7B33F480-496D-334A-BAC2-205DEC0CBC2D}
Visual Studio 2008 Professional SP1
{D7DAD1E4-45F4-3B2B-899A-EA728167EC4F}
32bit 30729.01
{F333A33D-125C-32A2-8DCE-5C5D14231E27}

So please decide, whether it's a good idea to check the presence of VCredist by GUIDs.

旧时光的容颜 2024-07-14 10:57:18

最可靠的方法是将 MsiQueryProductState API 与不同 vcredist 版本的 GUID 一起使用。

有用!

问候。

The surest way is using the MsiQueryProductState API with the GUID of the different vcredist versions.

It works!

Regards.

北恋 2024-07-14 10:57:18

找到 VC2008 可再发行组件的注册表项。 这是我的解决方案:

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;
    }
}

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