Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fixed issue where the System version of VS Code wasn't detected #12750

Merged
merged 5 commits into from
Jun 29, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/Files.App/Helpers/SoftwareHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,33 @@ public static bool IsVSCodeInstalled()
{
string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall";

var key = Registry.CurrentUser.OpenSubKey(registryKey);
return
ContainsName(Registry.CurrentUser.OpenSubKey(registryKey), "Microsoft Visual Studio Code") ||
ContainsName(Registry.LocalMachine.OpenSubKey(registryKey), "Microsoft Visual Studio Code");
ferrariofilippo marked this conversation as resolved.
Show resolved Hide resolved
}

public static bool IsVSInstalled()
{
string registryKey = @"SOFTWARE\Microsoft\VisualStudio";

var key = Registry.LocalMachine.OpenSubKey(registryKey);
if (key is null)
return false;

string? displayName;
key.Close();

return true;
}

private static bool ContainsName(RegistryKey? key, string find)
{
if (key is null)
return false;

foreach (var subKey in key.GetSubKeyNames().Select(key.OpenSubKey))
{
displayName = subKey?.GetValue("DisplayName") as string;
if (!string.IsNullOrWhiteSpace(displayName) && displayName.StartsWith("Microsoft Visual Studio Code"))
var displayName = subKey?.GetValue("DisplayName") as string;
if (!string.IsNullOrWhiteSpace(displayName) && displayName.StartsWith(find))
{
key.Close();

Expand All @@ -32,18 +49,5 @@ public static bool IsVSCodeInstalled()

return false;
}

public static bool IsVSInstalled()
{
string registryKey = @"SOFTWARE\Microsoft\VisualStudio";

var key = Registry.LocalMachine.OpenSubKey(registryKey);
if (key is null)
return false;

key.Close();

return true;
}
}
}