Skip to content

Commit

Permalink
old VS detection stabilization
Browse files Browse the repository at this point in the history
  • Loading branch information
preseverence committed Apr 10, 2017
1 parent ae8ffa5 commit 4f90662
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions VisualStudioOpener/VisualStudioDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ private static string CheckOldVisualStudio(RegistryKey key)

private static IEnumerable<IVisualStudioInfo> DetectOldVisualStudios()
{
RegistryKey registryHive = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32);

using (RegistryKey registryHive = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32))
using (RegistryKey key = registryHive.OpenSubKey(@"SOFTWARE\Microsoft\VisualStudio", false))
{
foreach (string subKeyName in key.GetSubKeyNames())
Expand All @@ -40,6 +39,8 @@ private static IEnumerable<IVisualStudioInfo> DetectOldVisualStudios()

using (RegistryKey subKey = key.OpenSubKey(subKeyName, false))
{
if (subKey == null)
continue;
string path = CheckOldVisualStudio(subKey);
if (path == null || !File.Exists(path))
continue;
Expand Down

0 comments on commit 4f90662

Please sign in to comment.