Skip to content

Commit

Permalink
Fix for #114
Browse files Browse the repository at this point in the history
This fixes the crash mentioned in #114 when multiple video controllers exist.  Naively picking the first entry may not work for everyone, but it seems to be the right choice most of the time.
  • Loading branch information
Nutzzz committed Feb 28, 2024
1 parent 3c163ad commit ec82728
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ public static string GetWMIProperty(string className, string propertyName)
var searcher = new ManagementObjectSearcher(selectQuery);

using var results = searcher.Get();
if (results.Count <= 0)
throw new Exception("Property from query is not found.");

var arr = new ManagementBaseObject[1];
var arr = new ManagementBaseObject[results.Count];
results.CopyTo(arr, 0);

var baseObject = arr[0];
Expand Down

0 comments on commit ec82728

Please sign in to comment.