Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Client Available RAM 1

Status
Not open for further replies.

CodingIsFun

Programmer
Apr 9, 2004
134
US
I am in the process of upgrading some software which requires me to know how much RAM is available on the client machine. In vb6 I used GlobalMemoryStatus Lib "kernel32".

Does anyone know the equivalent in vb.net

Thanks in advance...
 
System.Environment doesn't have anything relating to available memory. The System.Diagnostics.Process.MaxWorkingSet will tell you how much memory is available for use by your process.

You might also look into using WMI queries.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 

System.Diagnostics.Process.MaxWorkingSet does not exist as an option for me. Am I missing something?

System.Diagnostics.Process.GetCurrentProcess.MaxWorkingSet works though. Is this correct?

How would I convert the MaxWorkingSet to represent MB RAM?

Thanks again.
 
The reason why I mention this is because the number is not correct when I calculate MB Available RAM, assuming x is in Bytes (x/1028)/1000 = MB

I am getting a really low number..
 
That is the memory visible to the process, not how much is installed on the computer.

Sounds like you need to investigate WMI.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Thanks for pointing me in the correct direction. I was hoping someone would post a snippet because I'm lazy.

For anyone interested here is a class I have written to gather information:

Imports System.Management

Public Class clsWMI
Private objOS As ManagementObjectSearcher
Private objCS As ManagementObjectSearcher
Private objMgmt As ManagementObject
Private m_strComputerName As String
Private m_strManufacturer As String
Private m_StrModel As String
Private m_strOSName As String
Private m_strOSVersion As String
Private m_strSystemType As String
Private m_strTPM As String
Private m_strWindowsDir As String


Public Sub New()

objOS = New ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem")
objCS = New ManagementObjectSearcher("SELECT * FROM Win32_ComputerSystem")
For Each objMgmt In objOS.Get


m_strOSName = objMgmt("name").ToString()
m_strOSVersion = objMgmt("version").ToString()
m_strComputerName = objMgmt("csname").ToString()
m_strWindowsDir = objMgmt("windowsdirectory").ToString()
Next

For Each objMgmt In objCS.Get
m_strManufacturer = objMgmt("manufacturer").ToString()
m_StrModel = objMgmt("model").ToString()
m_strSystemType = objMgmt("systemtype").ToString
m_strTPM = objMgmt("totalphysicalmemory").ToString()
Next
End Sub

Public ReadOnly Property ComputerName()
Get
ComputerName = m_strComputerName
End Get

End Property
Public ReadOnly Property Manufacturer()
Get
Manufacturer = m_strManufacturer
End Get

End Property
Public ReadOnly Property Model()
Get
Model = m_StrModel
End Get

End Property
Public ReadOnly Property OsName()
Get
OsName = m_strOSName
End Get

End Property

Public ReadOnly Property OSVersion()
Get
OSVersion = m_strOSVersion
End Get

End Property
Public ReadOnly Property SystemType()
Get
SystemType = m_strSystemType
End Get

End Property
Public ReadOnly Property TotalPhysicalMemory()
Get
TotalPhysicalMemory = m_strTPM
End Get

End Property

Public ReadOnly Property WindowsDirectory()
Get
WindowsDirectory = m_strWindowsDir
End Get

End Property

End Class
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top