mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-19 04:43:21 +08:00
add try catch
This commit is contained in:
@@ -270,7 +270,13 @@ public static class Utils {
|
|||||||
using var root = Registry.LocalMachine;
|
using var root = Registry.LocalMachine;
|
||||||
using var sub = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")!;
|
using var sub = root.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall")!;
|
||||||
var installed = sub.GetSubKeyNames()
|
var installed = sub.GetSubKeyNames()
|
||||||
.Select(subKeyName => sub.OpenSubKey(subKeyName))
|
.Select(subKeyName => {
|
||||||
|
try {
|
||||||
|
return sub.OpenSubKey(subKeyName);
|
||||||
|
} catch (Exception) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
})
|
||||||
.Select(item => item?.GetValue("DisplayName") as string ?? string.Empty)
|
.Select(item => item?.GetValue("DisplayName") as string ?? string.Empty)
|
||||||
.Any(name => name.Contains("Microsoft Visual C++ 2022 X64 "));
|
.Any(name => name.Contains("Microsoft Visual C++ 2022 X64 "));
|
||||||
if (!installed) {
|
if (!installed) {
|
||||||
|
|||||||
Reference in New Issue
Block a user