Results 1 to 3 of 3

Thread: [RESOLVED] [1.0/1.1] Retrieving the total amount of RAM from a computer

  1. #1

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    Resolved [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?

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [1.0/1.1] Retrieving the total amount of RAM from a computer

    This might help.

  3. #3

    Thread Starter
    Hyperactive Member drattansingh's Avatar
    Join Date
    Sep 2005
    Posts
    395

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width