2020-07-30 21:02:06 +02:00
|
|
|
using Ryujinx.Common.Logging;
|
|
|
|
using System;
|
2020-05-04 04:15:27 +02:00
|
|
|
using System.Management;
|
2020-07-30 21:02:06 +02:00
|
|
|
using System.Runtime.InteropServices;
|
2020-11-27 18:57:20 +01:00
|
|
|
using System.Runtime.Versioning;
|
2020-05-04 04:15:27 +02:00
|
|
|
|
|
|
|
namespace Ryujinx.Common.SystemInfo
|
|
|
|
{
|
2020-11-27 18:57:20 +01:00
|
|
|
[SupportedOSPlatform("windows")]
|
2020-12-01 22:26:00 +01:00
|
|
|
internal class WindowsSystemInfo : SystemInfo
|
2020-05-04 04:15:27 +02:00
|
|
|
{
|
|
|
|
public override string CpuName { get; }
|
|
|
|
public override ulong RamSize { get; }
|
|
|
|
|
2020-12-01 22:26:00 +01:00
|
|
|
public WindowsSystemInfo()
|
2020-05-04 04:15:27 +02:00
|
|
|
{
|
2020-07-30 21:02:06 +02: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 04:15:27 +02:00
|
|
|
{
|
2020-07-30 21:02:06 +02:00
|
|
|
wmiNotAvailable = true;
|
|
|
|
}
|
|
|
|
catch (COMException)
|
|
|
|
{
|
|
|
|
wmiNotAvailable = true;
|
2020-05-04 04:15:27 +02:00
|
|
|
}
|
|
|
|
|
2020-07-30 21:02:06 +02:00
|
|
|
if (wmiNotAvailable)
|
2020-05-04 04:15:27 +02:00
|
|
|
{
|
2020-08-04 01:32:53 +02:00
|
|
|
Logger.Error?.Print(LogClass.Application, "WMI isn't available, system informations will use default values.");
|
2020-07-30 21:02:06 +02:00
|
|
|
|
|
|
|
CpuName = "Unknown";
|
2020-05-04 04:15:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|