How to get System Memory in C#.net windows application?
-
Hi , can anyone tell how to find the system memory using c#.net 3.5 windows application? Thanks In Advance. --Naren :-O
-
Hi , can anyone tell how to find the system memory using c#.net 3.5 windows application? Thanks In Advance. --Naren :-O
I suppose you could P/Invoke to
GlobalMemoryStatus
[^], for which you will need aMEMORYSTATUS
[^] There could be a better way though.. -
Hi , can anyone tell how to find the system memory using c#.net 3.5 windows application? Thanks In Advance. --Naren :-O
Hi, use the Ex versions, otherwise you will be in trouble when more than 2GB is present:
[DllImport("kernel32.dll")]
public static extern void GlobalMemoryStatusEx(ref MEMORYSTATUSEX ms);public struct MEMORYSTATUSEX {
///
public int Length; // DWORD
///
public int MemoryLoad; // DWORD
///
public long TotalPhys; // DWORDLONG
///
public long AvailPhys; // DWORDLONG
///
public long TotalPageFile; // DWORDLONG
///
public long AvailPageFile; // DWORDLONG
///
public long TotalVirtual; // DWORDLONG
///
public long AvailVirtual; // DWORDLONG
///
public long AvailExtendedVirtual; // DWORDLONG
}:)
Luc Pattyn [Forum Guidelines] [My Articles]
Avoiding unwanted divs (as in "articles needing approval") with the help of this FireFox add-in
modified on Monday, April 20, 2009 2:29 PM