mirror of
https://github.com/Ryujinx/Ryujinx.git
synced 2024-11-13 04:46:41 +00:00
16bab8fb88
* common: Fix WMI exception We currently don't check if WMI service is available when we get the CPU name and the RAM size. This fix the issue by catching all exceptions and set default values instead. Close #1353 * remove useless assign * Fix Exception * Address comments Co-authored-by: Thog <me@thog.eu>
46 lines
No EOL
1.4 KiB
C#
46 lines
No EOL
1.4 KiB
C#
using Ryujinx.Common.Logging;
|
|
using System;
|
|
using System.Management;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.Common.SystemInfo
|
|
{
|
|
internal class WindowsSysteminfo : SystemInfo
|
|
{
|
|
public override string CpuName { get; }
|
|
public override ulong RamSize { get; }
|
|
|
|
public WindowsSysteminfo()
|
|
{
|
|
bool wmiNotAvailable = false;
|
|
|
|
try
|
|
{
|
|
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;
|
|
}
|
|
|
|
if (wmiNotAvailable)
|
|
{
|
|
Logger.PrintError(LogClass.Application, "WMI isn't available, system informations will use default values.");
|
|
|
|
CpuName = "Unknown";
|
|
}
|
|
}
|
|
}
|
|
} |