نمایش مقدار حافظه فیزیکی و مجازی با ویژوال بیسیک

Private Type Memory
Length As Long
MemoryLoad As Long
TotalPhysMemory As Long
AvailablePhysMemory As Long
TotalPageFile As Long
AvailPageFile As Long
TotalVirtualMemory As Long
AvailableVirtualMemory As Long
End Type

Private Declare Sub GlobalMemoryStatus Lib "kernel32" (M As Memory)

Private Sub Timer1_Timer()
Dim M As Memory
GlobalMemoryStatus M
'*************************************************
LblAvlMem.Caption = Format(CDbl(M.AvailablePhysMemory / 1048576), "#.## MB")
LblTotalPhMem.Caption = Format(CDbl(M.TotalPhysMemory / 1048576), "#.## MB")
LblUsedMemory.Caption = Format(CDbl((M.TotalPhysMemory - M.AvailablePhysMemory) / 1048576), "#.## MB")
LblPercentPhMem.Caption = Format(CDbl((M.AvailablePhysMemory / M.TotalPhysMemory)), "##.#%")

'*************************************************
LblVirtualMem.Caption = Format(CDbl(M.AvailableVirtualMemory / 1048576), "#.## MB")
LblTotalVirtualMem.Caption = Format(CDbl(M.TotalVirtualMemory / 1048576), "#.## MB")
LblUsedVirtualMem.Caption = Format(CDbl((M.TotalVirtualMemory - M.AvailableVirtualMemory) / 1048576), "#.## MB")
LblPercentVirtualMem.Caption = Format(CDbl((M.AvailableVirtualMemory / M.TotalVirtualMemory)), "##.#%")
'*************************************************

End Sub