CodeItBetter Programming Another VB Programming Blog

How to access the computers memory

Posted on September 4, 2011
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
'System & API - How to access the computers memory
Public Declare Sub GlobalMemoryStatus Lib "kernel32" (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
 
Public memInfo As MemoryStatus
 
'Example of Physical Memory
Private Sub Form1_Load()
    Timer1.Enabled = True
End Sub
 
Private Sub Timer1_Timer()
    Dim physical
    physical = memInfo.dwTotalPhys - memInfo.dwAvailPhys
    label1.Caption = "Total Physical Memory: " & memInfo.dwTotalPhys
    label2.Caption = "Physical Memory being used: " & physical
    label3.Caption = "Percentage of usage: " & physical / memInfo.dwTotalPhys * 100 & "%"
End Sub
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.