Open Visual Studio.Net 2003, click File - New - Project - Console Application, Language Select C #, add the following method in the program, then join in the main () function
System.console.writeline ("System Memory is:" getPhisicalMemory (). TOSTRING ());
-------------------------------------------------- --------
Private int getPhisicalmemory ()
{
ManagementObjectSearcher Searcher = new managementObjectSearcher (); // Used to query some management objects such as system information
Searcher.Query = New SelectQuery ("Win32_PhysicalMemory", "", New String [] {"Capacity"}); // Setting the query condition
ManagementObjectCollection Collection = Searcher.get (); // Get memory capacity
ManagementObjectCollection.ManagementObjectCollection.ManagementObjectEnumerator em = Collection.GeteNumerator ();
INT CAPACITY = 0;
WHILE (em.movenext ())
{
ManagementBaseObject BaseObj = em.current;
IF (Baseobj.Properties ["Capacity"]. Value! = null)
{
Try
{
Capacity = int.parse (BaseObj.properties "[" Capacity "]. Value.toString ());
}
Catch
{
Messagebox.show ("There is an error! Please contact the software author! / N", "error message", MessageBoxButtons.ok, MessageBoxicon.Error, MessageBoxDefaultButton.Button1);
Return 0;
}
}
}
Return Capacity;