GlobalMemoryStatusEx Function

Declare Function GlobalMemoryStatusEx Lib "kernel32.dll" (lpBuffer As MEMORYSTATUSEX) As Long

Platforms

Description & Usage

GlobalMemoryStatusEx retrieves the current status of the computer's memory. It reports both the total memory available and the amount of unused memory.

Return Value

If an error occured, the function returns 0 (call GetLastError to get the error code). If successful, the function returns a non-zero value.

Visual Basic-Specific Issues

None.

Parameters

lpBuffer
Receives the current status of the computer's memory.

Example

' This code is licensed according to the terms and conditions listed here.

' Display the amounts of total and available physical memory
' on the computer.  Use the Currency data type to allow VB to display
' the 64-bit values reported by GlobalMemoryStatusEx.
Dim ms As MEMORYSTATUSEX
Dim temp As Currency  ' pseudo-64-bit integer buffer
Dim retval As Long  ' return value
Dim mult As Long  ' conversion multiplier

' Calculate the multiplier necessary to convert bytes in a Currency variable
' to kilobytes properly displayed:
mult = 10000 / 1024  ' move decimal point, bytes to kilobytes
' Get the current memory status.
retval = GlobalMemoryStatusEx(ms)

' Display total physical memory, in KB.
Debug.Print "Total Physical Memory:";
CopyMemory temp, ms.ullTotalPhys, Len(temp)
Debug.Print temp * mult; "KB"

' Display available physical memory, in KB.
Debug.Print "Available Physical Memory:";
CopyMemory temp, ms.ullAvailPhys, Len(temp)
Debug.Print temp * mult; "KB"

See Also

GlobalMemoryStatus

Category

Memory

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/globalmemorystatusex.html