MSDN.WhiteKnight - Stack Overflow answers
Ответ на "Как узнать количество доступной/всей оперативной памяти"
Answer 1171057
В Windows так:
using System; using System.Runtime.InteropServices; class Program { private struct MEMORYSTATUSEX { public uint dwLength; public uint dwMemoryLoad; public ulong ullTotalPhys; public ulong ullAvailPhys; public ulong ullTotalPageFile; public ulong ullAvailPageFile; public ulong ullTotalVirtual; public ulong ullAvailVirtual; public ulong ullAvailExtendedVirtual; } [DllImport("kernel32.dll")] static extern int GlobalMemoryStatusEx([In, Out] ref MEMORYSTATUSEX lpBuffer); //... MEMORYSTATUSEX ms = new MEMORYSTATUSEX(); ms.dwLength = (uint)Marshal.SizeOf(ms); if (GlobalMemoryStatusEx(ref ms) != 0) { uint available_ram = ms.ullAvailPhys; uint total_ram = ms.ullTotalPhys; } //... }
Content is retrieved from StackExchange API.
Auto-generated by ruso-archive tools.