0

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.

Community
  • 1
  • 1
Sonhja
  • 8,230
  • 20
  • 73
  • 131
  • Have you checked that the appropriate key is there in the registry on the machines where the application is not finding it? – Ben Robinson Sep 17 '14 at 16:24
  • Yes, it is. Actually, if you try to reinstall the Visual C++ again, it says "Repair, uninstall", so it's present! – Sonhja Sep 17 '14 at 17:11
  • What im trying to get at is your registry check a reliable way to see if it is installed or is it possible that your check fails because the keys you are checking are not set as you expect them to be even though it is installed – Ben Robinson Sep 17 '14 at 17:17
  • You mean that the flag is possible that is not installed in the places I mention? – Sonhja Sep 17 '14 at 17:18
  • Yes that's exactly what i mean. – Ben Robinson Sep 17 '14 at 17:19
  • Maybe that's the information I need, but since now the only thing I get is the info listed above. Do you have some more information on where can it be located? – Sonhja Sep 17 '14 at 17:21

1 Answers1

0

I would check the Installed value of

HKLM\SOFTWARE\[WOW6432Node]\Microsoft\Windows\CurrentVersion\Uninstall\{VCRedist_GUID} key

  • where GUID of VC++ 2012 (x86) is {33d1fd90-4274-48a1-9bc1-97e33d9c2d6f}
  • WOW6432Node will be present or not depending on the VC++ redist product
Learner
  • 3,297
  • 4
  • 37
  • 62