Jump to content
Xtreme .Net Talk

Recommended Posts

Posted
I've tried figureing this out but does anyone know how to get the amount of memory being used (in percentage), the total amount of memory, and the available memory?
Posted

I got this for vb6:

 

Dim ms As MEMORYSTATUS
   Dim msg As String
   
   ' query for memory data
   ms.dwLength = Len(ms)
   GlobalMemoryStatus ms
   ' create a result message.
   msg = "Total physical memory = " & GetKbytes(ms.dwTotalPhys) & vbCrLf & _
       "Available physical memory = " & GetKbytes(ms.dwAvailPhys) & vbCrLf & _
       "Memory Load = " & ms.dwMemoryLoad & "%" & vbCrLf & _
       "Total Page file = " & GetKbytes(ms.dwTotalPageFile) & vbCrLf & _
       "Available Page file = " & GetKbytes(ms.dwAvailPageFile) & vbCrLf & _
       "Total Virtual memory = " & GetKbytes(ms.dwTotalVirtual) & vbCrLf & _
       "Available Virtual memory = " & GetKbytes(ms.dwAvailVirtual)
   MsgBox msg, vbInformation, "Memory information"

'The GetKbytes function is a simple routine that converts a number of bytes into Kbytes, and adds thousand separators: 
' Format a memory amoung as a Kbyte or Megabyte

Function GetKbytes(ByVal amount As Long) As String
   ' convert to Kbytes
   amount = amount \ 1024
   GetKbytes = Format(amount, "###,###,###K")
End Function

 

The problem is that it's in vb6, and i need vb.net

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...