diff --git a/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs b/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs index 1d4e61faf9..6bbed21565 100644 --- a/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs +++ b/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs @@ -1,4 +1,7 @@ +using Ryujinx.Common.Logging; +using System; using System.Management; +using System.Runtime.InteropServices; namespace Ryujinx.Common.SystemInfo { @@ -9,14 +12,34 @@ namespace Ryujinx.Common.SystemInfo public WindowsSysteminfo() { - foreach (ManagementBaseObject mObject in new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor").Get()) + bool wmiNotAvailable = false; + + try { - CpuName = mObject["Name"].ToString(); + foreach (ManagementBaseObject mObject in new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_Processor").Get()) + { + CpuName = mObject["Name"].ToString(); + } + + foreach (ManagementBaseObject mObject in new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem").Get()) + { + RamSize = ulong.Parse(mObject["TotalVisibleMemorySize"].ToString()) * 1024; + } + } + catch (PlatformNotSupportedException) + { + wmiNotAvailable = true; + } + catch (COMException) + { + wmiNotAvailable = true; } - foreach (ManagementBaseObject mObject in new ManagementObjectSearcher("root\\CIMV2", "SELECT * FROM Win32_OperatingSystem").Get()) + if (wmiNotAvailable) { - RamSize = ulong.Parse(mObject["TotalVisibleMemorySize"].ToString()) * 1024; + Logger.PrintError(LogClass.Application, "WMI isn't available, system informations will use default values."); + + CpuName = "Unknown"; } } }