2020-07-30 19:02:06 +00:00
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
using System;
|
2020-05-04 02:15:27 +00:00
|
|
|
using System.Management;
|
2020-07-30 19:02:06 +00:00
|
|
|
using System.Runtime.InteropServices;
|
2020-05-04 02:15:27 +00:00
|
|
|
|
|
|
|
namespace Ryujinx.Common.SystemInfo
|
|
|
|
{
|
|
|
|
internal class WindowsSysteminfo : SystemInfo
|
|
|
|
{
|
|
|
|
public override string CpuName { get; }
|
|
|
|
public override ulong RamSize { get; }
|
|
|
|
|
|
|
|
public WindowsSysteminfo()
|
|
|
|
{
|
2020-07-30 19:02:06 +00:00
|
|
|
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)
|
2020-05-04 02:15:27 +00:00
|
|
|
{
|
2020-07-30 19:02:06 +00:00
|
|
|
wmiNotAvailable = true;
|
|
|
|
}
|
|
|
|
catch (COMException)
|
|
|
|
{
|
|
|
|
wmiNotAvailable = true;
|
2020-05-04 02:15:27 +00:00
|
|
|
}
|
|
|
|
|
2020-07-30 19:02:06 +00:00
|
|
|
if (wmiNotAvailable)
|
2020-05-04 02:15:27 +00:00
|
|
|
{
|
2020-07-30 19:02:06 +00:00
|
|
|
Logger.PrintError(LogClass.Application, "WMI isn't available, system informations will use default values.");
|
|
|
|
|
|
|
|
CpuName = "Unknown";
|
2020-05-04 02:15:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|