[RESOLVED] [1.0/1.1] Retrieving the total amount of RAM from a computer
Hi. Does anyone know how to retrieve the amount of RAM in megabytes from a computer?
Re: [1.0/1.1] Retrieving the total amount of RAM from a computer
Re: [1.0/1.1] Retrieving the total amount of RAM from a computer
Thanks Hack. This is the solution:
Code:
using System.Runtime.InteropServices; // To use Dll import.
....
[DllImport("kernel32.dll")]
public static extern void GlobalMemoryStatus(out MemoryStatus stat);
public struct MemoryStatus
{
public uint Length; //Length of struct
public uint MemoryLoad; //Value from 0-100 represents memory usage
public uint TotalPhysical; // The total RAM.
public uint AvailablePhysical; // The Available RAM.
public uint TotalPageFile;
public uint AvailablePageFile;
public uint TotalVirtual;
public uint AvailableVirtual;
}
......
MemoryStatus MemStat = new MemoryStatus();
GlobalMemoryStatus(out MemStat);
......
Console.WriteLine(MemStat.TotalPhysical/1024/1024.ToString());
...// To access available RAM, MemStat.AvailablePhysical
Jennifer :thumb: