Tuesday, May 5, 2009

How To Check the Memory usage?

'follow the code to check the usage of your computer memory.

Take four labels and set captions as

Lbl1: Caption="Memory"

Lbl2: 

Lbl3: Caption=" Use"

Lbl4:

A Command Button named Cmd1



'and here code

Private Declare Sub GlobalMemoryStatus Lib "KERNEL32" (lpBuffer As MEMORYSTATUS)

Dim mem As MEMORYSTATUS

Private 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

Private Sub Command1_Click()
GlobalMemoryStatus mem

Label2.Caption = Format(mem.dwTotalPhys / 1048576, standard) & "Mb"

Label4.Caption = mem.dwMemoryLoad & "%"


End Sub



Try it and use it to enhance your small projects...........

4 comments: