From bc0170976c5cba7f76d7f8052d9d1e31769dceab Mon Sep 17 00:00:00 2001 From: dbuechel Date: Fri, 20 Dec 2019 17:52:38 +0100 Subject: [PATCH] SEBWIN-316: Ensured Windows 7 & 8.1 support for computer system information. --- .../SystemInfo.cs | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/SafeExamBrowser.SystemComponents/SystemInfo.cs b/SafeExamBrowser.SystemComponents/SystemInfo.cs index 0277854b..f2bd3c16 100644 --- a/SafeExamBrowser.SystemComponents/SystemInfo.cs +++ b/SafeExamBrowser.SystemComponents/SystemInfo.cs @@ -45,14 +45,36 @@ namespace SafeExamBrowser.SystemComponents private void InitializeMachineInfo() { + var model = string.Empty; + var systemFamily = string.Empty; + using (var searcher = new ManagementObjectSearcher("Select * from Win32_ComputerSystem")) using (var results = searcher.Get()) - using (var system = results.Cast().FirstOrDefault()) + using (var system = results.Cast().First()) { - Manufacturer = Convert.ToString(system["Manufacturer"]); - Model = string.Join(" ", Convert.ToString(system["SystemFamily"]), Convert.ToString(system["Model"])); - Name = Convert.ToString(system["Name"]); + foreach (var property in system.Properties) + { + if (property.Name.Equals("Manufacturer")) + { + Manufacturer = Convert.ToString(property.Value); + } + else if (property.Name.Equals("Model")) + { + model = Convert.ToString(property.Value); + } + else if (property.Name.Equals("Name")) + { + Name = Convert.ToString(property.Value); + } + else if (property.Name.Equals("SystemFamily")) + { + systemFamily = Convert.ToString(property.Value); + } + } + } + + Model = string.Join(" ", systemFamily, model); } private void InitializeOperatingSystem()