AllAPI Network - The KPD-Team

 
Allapi Network
 API-Guide
 ApiViewer

 API List

 
API Resources
 Tips & Tricks
 VB Tutorials
 Error Lookup
 
Misc Stuff
 VB examples
 VB Tools
 VB Links
 Top Downloads
 
This Site
 Search Engine
 Contact Form
 

Donate to AllAPI.net

Finding out the amount of free memory

It is easy to return the amount of free memory in windows, using the GlobalMemoryStatus API call. Insert the following into a module's declarations section:

Public Type MEMORYSTATUS 
dwLength As Long 
dwMemoryLoad As Long 
dwTotalPhys As Long 
dwAvailPhys As Long 
dwTotalPageFile As Long 
dwAvailPageFile As Long 
dwTotalVirtual As Long 
dwAvailVirtual As Long
End Type

Public Declare Sub GlobalMemoryStatus _
Lib "kernel32" (lpBuffer As MEMORYSTATUS)

Now, add this code to get the values:

Dim MS As MEMORYSTATUS 
MS.dwLength = Len(MS) 
GlobalMemoryStatus MS

' MS.dwMemoryLoad contains percentage memory used
' MS.dwTotalPhys contains total amount of physical memory in bytes
' MS.dwAvailPhys contains available physical memory
' MS.dwTotalPageFile contains total amount of memory in the page file
' MS.dwAvailPageFile contains available amount of memory in the page file
' MS.dwTotalVirtual contains total amount of virtual memory
' MS.dwAvailVirtual contains available virtual memory

You could use this in about boxes or making a memory monitoring system.

 

 


Copyright © 1998-2007, The Mentalis.org Team - Privacy statement
Did you find a bug on this page? Tell us!
This site is located at http://allapi.mentalis.org/