Use CsWin32 (#1912)
* Use CsWin32 * Update LibreHardwareMonitorLib/Hardware/Cpu/CpuLoad.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update LibreHardwareMonitorLib/Hardware/Battery/BatteryGroup.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update pull requests.yml * Update pull requests.yml * Update master.yml * A couple more to CsWin32 * Restore PawnIO defaults Fixes #1910 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -4,34 +4,34 @@
|
||||
// Partial Copyright (C) Michael Möller <mmoeller@openhardwaremonitor.org> and Contributors.
|
||||
// All Rights Reserved.
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using LibreHardwareMonitor.Interop;
|
||||
using Windows.Win32;
|
||||
using Windows.Win32.System.SystemInformation;
|
||||
|
||||
namespace LibreHardwareMonitor.Hardware.Memory;
|
||||
|
||||
internal static class MemoryWindows
|
||||
internal static unsafe class MemoryWindows
|
||||
{
|
||||
public static void Update(TotalMemory memory)
|
||||
{
|
||||
Kernel32.MEMORYSTATUSEX status = new() { dwLength = (uint)Marshal.SizeOf<Kernel32.MEMORYSTATUSEX>() };
|
||||
MEMORYSTATUSEX status = new() { dwLength = (uint)sizeof(MEMORYSTATUSEX) };
|
||||
|
||||
if (!Kernel32.GlobalMemoryStatusEx(ref status))
|
||||
if (!PInvoke.GlobalMemoryStatusEx(ref status))
|
||||
return;
|
||||
|
||||
memory.PhysicalMemoryUsed.Value = (float)(status.ullTotalPhys - status.ullAvailPhys) / (1024 * 1024 * 1024);
|
||||
memory.PhysicalMemoryUsed.Value = (float)(status.ullTotalPhys - status.ullAvailPhys) / (1024 * 1024 * 1024);
|
||||
memory.PhysicalMemoryAvailable.Value = (float)status.ullAvailPhys / (1024 * 1024 * 1024);
|
||||
memory.PhysicalMemoryLoad.Value = 100.0f - ((100.0f * status.ullAvailPhys) / status.ullTotalPhys);
|
||||
memory.PhysicalMemoryLoad.Value = 100.0f - ((100.0f * status.ullAvailPhys) / status.ullTotalPhys);
|
||||
}
|
||||
|
||||
public static void Update(VirtualMemory memory)
|
||||
{
|
||||
Kernel32.MEMORYSTATUSEX status = new() { dwLength = (uint)Marshal.SizeOf<Kernel32.MEMORYSTATUSEX>() };
|
||||
MEMORYSTATUSEX status = new() { dwLength = (uint)sizeof(MEMORYSTATUSEX) };
|
||||
|
||||
if (!Kernel32.GlobalMemoryStatusEx(ref status))
|
||||
if (!PInvoke.GlobalMemoryStatusEx(ref status))
|
||||
return;
|
||||
|
||||
memory.VirtualMemoryUsed.Value = (float)(status.ullTotalPageFile - status.ullAvailPageFile) / (1024 * 1024 * 1024);
|
||||
memory.VirtualMemoryUsed.Value = (float)(status.ullTotalPageFile - status.ullAvailPageFile) / (1024 * 1024 * 1024);
|
||||
memory.VirtualMemoryAvailable.Value = (float)status.ullAvailPageFile / (1024 * 1024 * 1024);
|
||||
memory.VirtualMemoryLoad.Value = 100.0f - ((100.0f * status.ullAvailPageFile) / status.ullTotalPageFile);
|
||||
memory.VirtualMemoryLoad.Value = 100.0f - ((100.0f * status.ullAvailPageFile) / status.ullTotalPageFile);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user