In this post I will show you how you can get the Total Ram of your computer. This example is in VB.net, after explaining the code I will tell you how you can use this code in your C# language and get the total memory of the computer. To get the total memory of the computer what you have to do is to import the Microsoft.VisualBasic.Devices namespace in your file and then use the ComputerInfo class of that namespace. The ComputerInfo class Provides properties for getting information about the computer's memory, loaded assemblies, name, and operating system. Here are some of the useful properties which are used to get the total physical and virtual memory.
|AvailablePhysicalMemory||Gets the total amount of free physical memory for the computer|
|AvailableVirtualMemory||Gets the total amount of the computer's free virtual address space.|
|TotalPhysicalMemory||A double-precision floating point number data type|
|TotalVirtualMemory||Gets the total amount of virtual address space available for the computer.|
Here is the code which is used to get the Available Physical Memory, Available Virtual Memory, Total Physical Memory and the Total Virtual Memory.
And here is the output of the above code. Which display the Available Physical Memory, Available Virtual Memory, Total Physical Memory and the Total Virtual Memory.
If you want to use this code in your C# language what you have to do is to import the Microsoft.VisualBasic.Devices name space by using the using Statement in you file and then you will have the ComputerInfo class accessible in you code and you can use that class to get the information.
All and any comments / bugs / suggestions are welcomed!