summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/System.cs12
-rw-r--r--win/C#/HandBrake.ApplicationServices/Functions/Win32.cs62
2 files changed, 23 insertions, 51 deletions
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/System.cs b/win/C#/HandBrake.ApplicationServices/Functions/System.cs
index b2ee6edfe..9b08a4be2 100644
--- a/win/C#/HandBrake.ApplicationServices/Functions/System.cs
+++ b/win/C#/HandBrake.ApplicationServices/Functions/System.cs
@@ -18,17 +18,15 @@ namespace HandBrake.ApplicationServices.Functions
/// Gets the total physical ram in a system
/// </summary>
/// <returns>The total memory in the system</returns>
- public static uint TotalPhysicalMemory
+ public static ulong TotalPhysicalMemory
{
get
{
- Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();
- Win32.GlobalMemoryStatus(ref memStatus);
+ Win32.MEMORYSTATUSEX memStat = new Win32.MEMORYSTATUSEX { dwLength = 64 };
+ Win32.GlobalMemoryStatusEx(ref memStat);
- uint memoryInfo = memStatus.dwTotalPhys;
- memoryInfo = memoryInfo / 1024 / 1024;
-
- return memoryInfo;
+ ulong value = memStat.ullTotalPhys / 1024 / 1024;
+ return value;
}
}
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs
index ce36a9c1f..8cb464b80 100644
--- a/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs
+++ b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs
@@ -47,59 +47,33 @@ namespace HandBrake.ApplicationServices.Functions
public static extern int ExitWindowsEx(int uFlags, int dwReason);
/// <summary>
- /// System Memory Status
+ /// Memory Status EX Struct
/// </summary>
- public struct MEMORYSTATUS // Unused var's are required here.
+ public struct MEMORYSTATUSEX
{
- /// <summary>
- /// Unknown
- /// </summary>
- public UInt32 dwLength;
-
- /// <summary>
- /// Memory Load
- /// </summary>
- public UInt32 dwMemoryLoad;
-
- /// <summary>
- /// Total Physical Memory
- /// </summary>
- public UInt32 dwTotalPhys; // Used
-
- /// <summary>
- /// Available Physical Memory
- /// </summary>
- public UInt32 dwAvailPhys;
-
- /// <summary>
- /// Total Page File
- /// </summary>
- public UInt32 dwTotalPageFile;
-
- /// <summary>
- /// Available Page File
- /// </summary>
- public UInt32 dwAvailPageFile;
-
- /// <summary>
- /// Total Virtual Memory
- /// </summary>
- public UInt32 dwTotalVirtual;
-
- /// <summary>
- /// Available Virtual Memory
- /// </summary>
- public UInt32 dwAvailVirtual;
+ public int dwLength;
+ public int dwMemoryLoad;
+ public ulong ullTotalPhys;
+ public ulong ullAvailPhys;
+ public ulong ullTotalPageFile;
+ public ulong ullAvailPageFile;
+ public ulong ullTotalVirtual;
+ public ulong ullAvailVirtual;
+ public ulong ullAvailExtendedVirtual;
}
/// <summary>
- /// Global Memory Status
+ /// Get the System Memory information
/// </summary>
/// <param name="lpBuffer">
/// The lp buffer.
/// </param>
- [DllImport("kernel32.dll")]
- public static extern void GlobalMemoryStatus(ref MEMORYSTATUS lpBuffer);
+ /// <returns>
+ /// A boolean.
+ /// </returns>
+ [DllImport("kernel32.dll", SetLastError = true)]
+ public static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);
+
/// <summary>
/// Generate a Console Ctrl Event