How to return the amount of free memory in windows.
Posted on January 4, 2009
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 'System & API - How to return the amount of free memory in windows. Public Declare Sub GlobalMemoryStatus Lib "kernel32" _ Alias "GlobalMemoryStatus" _ (lpBuffer As MEMORYSTATUS) 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 Global Mem as MEMORYSTATUS 'Add this code to get the values: Mem.dwLength = Len(Mem) GlobalMemoryStatus Mem 'After calling the GlobalMemoryStatus API, 'you can use the MEMORYSTATUS type to access 'the memory information: 'Mem.dwMemoryLoad contains percentage memory used 'Mem.dwTotalPhys - total amount of physical memory 'Mem.dwAvailPhys - available amount of physical memory 'Mem.dwTotalPageFile - total amount of memory in swap file 'Mem.dwAvailPageFile - available amount of memory in swap file 'Mem.dwTotalVirtual - total amount of virtual memory 'Mem.dwAvailVirtual - available amount of virtual memory 'You can use the following to set the caption 'of Label1 to the amount of physical memory available: Label1.Caption = Str(Mem.dwAvailPhys) |