CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2004
    Posts
    2

    ASP.net Programming

    Hi,

    I want to determine the RAM(memory) on the user's system, and then
    display the appropriate web page to the user. I just want to know how to do it ASP.net.

    Can anyone help me out?

    Vinay

  2. #2
    Join Date
    Dec 2002
    Location
    Birmingham, AL
    Posts
    82
    You'll have to do it with unmanaged code.

    You need a new class file named Memory.cs (assuming C#)
    Code:
    using System;
    using System.Runtime.InteropServices;
    
    namespace Memory
    {
    	public class Memory
    	{
    		private struct MEMORYSTATUS
    		{
    			public int dwLength;
    			public int ddwMemoryLoad;
    			public int dwTotalPhys;
    			public int dwAvailPhys;
    			public int dwTotalPageFile;
    			public int dwAvailPageFile;
    			public int dwTotalVirtual;
    			public int dwAvailVirtual;
    		}
    
    		[DllImport ("kernel32.dll")]
    		private static extern void GlobalMemoryStatus(ref MEMORYSTATUS lpMem);
    
    		private MEMORYSTATUS memStat;
    
    		public int GetTotalMemory()
    		{
    			GlobalMemoryStatus(ref memStat);
    			return memStat.dwTotalPhys / 1024;
    		}
    
    		public Memory()
    		{
    		}
    	}
    }
    and the Page_Load or other Event
    Code:
    private void Page_Load(object sender, System.EventArgs e)
    {
    	Memory mem = new Memory();
    
    	Label1.Text = "Total Memory = " + mem.GetTotalMemory().ToString() + " KB";
    
    }

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

Featured