diff options
Diffstat (limited to 'Ryujinx.Common')
| -rw-r--r-- | Ryujinx.Common/Ryujinx.Common.csproj | 1 | ||||
| -rw-r--r-- | Ryujinx.Common/SystemInfo.cs | 41 |
2 files changed, 42 insertions, 0 deletions
diff --git a/Ryujinx.Common/Ryujinx.Common.csproj b/Ryujinx.Common/Ryujinx.Common.csproj index 26fb73c4..e902d26a 100644 --- a/Ryujinx.Common/Ryujinx.Common.csproj +++ b/Ryujinx.Common/Ryujinx.Common.csproj @@ -31,6 +31,7 @@ <NoWarn>NU1701</NoWarn> </PackageReference> <PackageReference Include="MsgPack.Cli" Version="1.0.1" /> + <PackageReference Include="System.Management" Version="4.7.0" /> <PackageReference Include="Utf8Json" Version="1.3.7" /> </ItemGroup> diff --git a/Ryujinx.Common/SystemInfo.cs b/Ryujinx.Common/SystemInfo.cs new file mode 100644 index 00000000..dbe02617 --- /dev/null +++ b/Ryujinx.Common/SystemInfo.cs @@ -0,0 +1,41 @@ +using System; +using System.IO; +using System.Linq; +using System.Management; +using System.Runtime.InteropServices; + +namespace Ryujinx.Common +{ + public static class SystemInfo + { + public static string OsDescription { get; private set; } + public static string CpuName { get; private set; } + public static string RamSize { get; private set; } + + static SystemInfo() + { + OsDescription = $"{RuntimeInformation.OSDescription} ({RuntimeInformation.OSArchitecture})"; + CpuName = "Unknown"; + RamSize = "Unknown"; + + if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + { + 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 = $"{Math.Round(double.Parse(mObject["TotalVisibleMemorySize"].ToString()) / 1024, 0)} MB"; + } + } + + else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) + { + CpuName = File.ReadAllLines("/proc/cpuinfo").Where(line => line.StartsWith("model name")).ToList()[0].Split(":")[1].Trim(); + RamSize = $"{Math.Round(double.Parse(File.ReadAllLines("/proc/meminfo")[0].Split(":")[1].Trim().Split(" ")[0]) / 1024, 0)} MB"; + } + } + } +}
\ No newline at end of file |
