diff options
author | sr55 <[email protected]> | 2010-12-03 20:58:51 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-12-03 20:58:51 +0000 |
commit | 5d6b22826353d5028799362292cd85e5da91cfaf (patch) | |
tree | 0378abb65a5d0cc38a159e1e6fbf7fe2a8ccfad5 /win/C# | |
parent | d46ec09d3c22bdbe00d725794aee4d9d2ade3d8a (diff) |
WinGui:
- Fix Memory Detection on 64bit systems when the system has >4GB of ram.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3698 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#')
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Functions/System.cs | 12 | ||||
-rw-r--r-- | win/C#/HandBrake.ApplicationServices/Functions/Win32.cs | 62 |
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
|