Declare Sub GlobalMemoryStatus Lib "kernel32.dll" (lpBuffer As MEMORYSTATUS)
GlobalMemoryStatus retrieves the current status of the computer's memory. It reports both the total memory available and the amount of unused memory. This function only works properly on computers with no more than 4 GB of memory. If the computer has more than 4 GB of memory, the values reported by GlobalMemoryStatus are the actual values modulo 4 (for example, a computer with 5 GB total memory would be reported as having only 1 GB of memory). For computers with more than 4 GB of memory, use the GlobalMemoryStatusEx function instead.
GlobalMemoryStatusEx does not return a value.
None.
' This code is licensed according to the terms and conditions listed here.
' Display the amounts of total and available physical memory
' on the computer. Also calculate the percentage of used physical memory.
Dim ms As MEMORYSTATUS
' Get the current memory status.
GlobalMemoryStatus ms
' Display total and available physical memory, in KB.
Debug.Print "Total Physical Memory:"; ms.dwTotalPhys \ 1024; "KB"
Debug.Print "Available Physical Memory:"; ms.dwAvailPhys \ 1024; "KB"
' Calculate percentage of physical memory in use.
Debug.Print "Used Physical Memory:"; 100 - 100 * ms.dwAvailPhys \ ms.dwTotalPhys; "%"
Back to the Function list.
Back to the Reference section.
Last Modified: March 19, 2000
This page is copyright © 2000 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/g/globalmemorystatus.html