Click to See Complete Forum and Search --> : ASP.net Programming


vinaygutta
April 2nd, 2004, 05:23 AM
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

wey97
April 6th, 2004, 09:57 AM
You'll have to do it with unmanaged code.

You need a new class file named Memory.cs (assuming C#)


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

private void Page_Load(object sender, System.EventArgs e)
{
Memory mem = new Memory();

Label1.Text = "Total Memory = " + mem.GetTotalMemory().ToString() + " KB";

}