Skip to content

Commit 3745b0f

Browse files
committed
Fix the issue where certain remote desktop software may generate drivers with unknown device types, causing null values in the values obtained by GetGPUNames, which leads to program crash during startup
1 parent eb1b2a7 commit 3745b0f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

QuickLook/NativeMethods/WMI.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public static List<string> GetGPUNames()
3333
List<string> names = [];
3434

3535
foreach (var obj in searcher.Get())
36-
names.Add(obj["Name"] as string);
36+
if (obj["Name"] is string name)
37+
names.Add(name);
3738

3839
return names;
3940
}
@@ -49,6 +50,7 @@ public static List<string> GetGPUNames()
4950
{
5051
Debug.WriteLine($"General exception caught: {e.Message}");
5152
}
53+
5254
return [];
5355
}
54-
}
56+
}

0 commit comments

Comments
 (0)