VBA/Excel/Access/Word/Windows API/System Memory
Get System Memory Size
<source lang="vb">
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 Type SYSTEM_INFO
dwOemID As Long dwPageSize As Long lpMinimumApplicationAddress As Long lpMaximumApplicationAddress As Long dwActiveProcessorMask As Long dwNumberOrfProcessors As Long dwProcessorType As Long dwAllocationGranularity As Long dwReserved As Long
End Type Declare Sub abGlobalMemoryStatus Lib "kernel32" Alias "GlobalMemoryStatus" (lpBuffer As MEMORYSTATUS) Sub GetSysInfo()
Dim intMousePresent As Integer Dim strBuffer As String Dim intLen As Integer Dim MS As MEMORYSTATUS Dim SI As SYSTEM_INFO
"Set the length member before you call GlobalMemoryStatus MS.dwLength = Len(MS) abGlobalMemoryStatus MS Debug.Print "MemoryLoad" & MS.dwMemoryLoad & "%" Debug.Print "TotalPhysical" & Format(Fix(MS.dwTotalPhys / 1024), "###,###") & "K" Debug.Print "AvailablePhysical" & Format(Fix(MS.dwAvailPhys / 1024), "###,###") & "K" Debug.Print "TotalVirtual" & Format(Fix(MS.dwTotalVirtual / 1024), "###,###") & "K" Debug.Print "AvailableVirtual" & Format(Fix(MS.dwAvailVirtual / 1024), "###,###") & "K"
End Sub
</source>