Develop and Download Open Source Software

Browse Subversion Repository

Contents of /NeoFT/Win32Util/GlobalMemoryInfo.cs

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1 - (show annotations) (download)
Tue Mar 25 12:06:05 2008 UTC (16 years ago) by c477
File size: 1433 byte(s)


1 using System;
2 using System.Runtime.InteropServices;
3
4 namespace nft.win32util
5 {
6 /// <summary>
7 /// Get global memory informations.
8 /// each values are obtained when the object created.
9 /// </summary>
10 public class GlobalMemoryInfo
11 {
12
13 [DllImport("kernel32.dll")]
14 extern static void GlobalMemoryStatus(ref MemoryStatus lpBuffer) ;
15
16 struct MemoryStatus
17 {
18 public int dwLength ;
19 public int dwMemoryLoad ;
20 public int dwTotalPhys ; // physical memory total
21 public int dwAvailPhys ; // physical memory available
22 public int dwTotalPageFile ; // page files total
23 public int dwAvailPageFile ; // page files available
24 public int dwTotalVirtual ; // virtual memory total
25 public int dwAvailVirtual ; // virtual memory available
26 }
27
28 private readonly MemoryStatus msinfo;
29
30 public GlobalMemoryInfo()
31 {
32 msinfo = new MemoryStatus();
33 msinfo.dwLength = Marshal.SizeOf(msinfo);
34 GlobalMemoryStatus(ref msinfo);
35 }
36
37 public int PhysicalMemTotal { get { return msinfo.dwTotalPhys; } }
38 public int PhysicalMemAvailable { get { return msinfo.dwAvailPhys; } }
39 public int PageFileTotal { get { return msinfo.dwTotalPageFile; } }
40 public int PageFileAvailable { get { return msinfo.dwAvailPageFile; } }
41 public int VirtualMemTotal { get { return msinfo.dwTotalVirtual; } }
42 public int VirtualMemAvailable { get { return msinfo.dwAvailVirtual; } }
43 }
44 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26