I have a custom application that needs to check if Visual C++ 2012 Redistributable
is installed in my machine.
I googled, and I found that the physical path in the Windows Registry (that you can search using Regedit) are the following:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\11.0\VC\Runtimes\x86
and
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\11.0\VC\Runtimes\x86
You can see these links in this Stack answer.
But for some reasons, my application doesn't find it sometimes. In this cases, I'm using two different Admin accounts for installing them, but I think it makes no difference.
I also found these other locations to look. But I'm not using them. Here's my code:
....
bool vc2012Installed = CheckVisualRedistributable(vc2012RedistRoutes);
....
private bool CheckVisualRedistributable(string[] redistCheck)
{
try
{
int installed = -1;
foreach (string route in redistCheck)
{
RegistryKey vcRedistKey = Registry.LocalMachine.OpenSubKey(route);
if (vcRedistKey == null) { continue; }
installed = (int)vcRedistKey.GetValue("Installed");
if (installed == 1) break;
}
if (installed == -1) return false;
return true;
}
catch (Exception ex)
{
MessageBox.Show("CheckVisualRedistributable: " + ex.Message);
return false;
}
}
But I don't know why in some cases the C++ Redistributable 2012
is not being detected...
Any idea on what might be wrong? Maybe a user account problem?
NOTE: Problems appear on Windows 8.1. Works fine on Windows 7.