Reputation: 1
How can I detect when "Visual C++ 2013 redistributable" is installed?
The following c++ code detects the 2010 redist correctly:
// Visual C++ 2010 Redist detection...
INSTALLSTATE state = pMsiProc( _T("{F0C3E5D1-1ADE-321E-8167-68EF0DE699A5}") );
if(state == INSTALLSTATE_DEFAULT)
{
// Visual C++ 2010 redist installed.
}
I was hoping to use the same sort of code for 2013 redist, but the INSTALLSTATE always returns INSTALLSTATE_DEFAULT whether the package is installed or not. Anyone know why?
// call MsiQueryProductStateW...
INSTALLSTATE state = pMsiProc(_T("{13A4EE12-23EA-3371-91EEEFB36DDFFF3E}"));
//
if ((state == INSTALLSTATE_DEFAULT || state == INSTALLSTATE_LOCAL)
{
// 2013 redist is installed.
}
Upvotes: 0
Views: 2078
Reputation: 4590
As an alternative, you can enumerate the registry looking at the "Displayname" key for the following tokens: 'Microsoft', 'Visual', 'C++', 'Redistributable'. You can use the following to determine if the sub-key is what you're after...
// search for valid tokens to indicate this is a redistributable.
resToken = name.Tokenize (_T(" "), curPos);
while (resToken != _T(""))
{
if (resToken == _T("Microsoft"))
tokenCount |= 0x01;
if (resToken == _T("Visual"))
tokenCount |= 0x02;
if (resToken == _T("C++"))
tokenCount |= 0x04;
if (resToken == _T("Redistributable"))
tokenCount |= 0x08;
resToken = name.Tokenize (_T(" "), curPos);
}
// check for matching tokens in the Display Name.
if (tokenCount == 0x0f)
{
Simply start your search at "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" and enumerate all of the sub-keys for the above values. You would also need to check both the 32 and 64 bit hives.
Upvotes: 0
Reputation: 401
Are you on a x86 architecture? If not, the code is different: https://allthingsconfigmgr.wordpress.com/2013/12/17/visual-c-redistributables-made-simple/
Upvotes: 1