From 3745b0fd3b0812600377ab8bdee4b68d17782f93 Mon Sep 17 00:00:00 2001 From: josc146 Date: Mon, 20 Jan 2025 13:45:50 +0800 Subject: [PATCH] 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 --- QuickLook/NativeMethods/WMI.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/QuickLook/NativeMethods/WMI.cs b/QuickLook/NativeMethods/WMI.cs index a88ee5282..e306100e2 100644 --- a/QuickLook/NativeMethods/WMI.cs +++ b/QuickLook/NativeMethods/WMI.cs @@ -33,7 +33,8 @@ public static List GetGPUNames() List names = []; foreach (var obj in searcher.Get()) - names.Add(obj["Name"] as string); + if (obj["Name"] is string name) + names.Add(name); return names; } @@ -49,6 +50,7 @@ public static List GetGPUNames() { Debug.WriteLine($"General exception caught: {e.Message}"); } + return []; } -} +} \ No newline at end of file