Reputation: 1588
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 :)
Upvotes: 21
Views: 48607
Reputation: 16960
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 SP1 redistributable package product codes
Upvotes: 14
Reputation: 8394
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:
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.
Upvotes: 3
Reputation: 1588
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
² The path:
$WINDIR\WinSxS\x86_Microsoft.VC90.CRT_1fc8b3b9a1e18e3b_9.0.30729*
Upvotes: 6
Reputation: 11243
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.
Upvotes: 8