CodeItBetter Programming Another VB Programming Blog

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)

Related posts:

  1. How to get amount Of free And used memory
  2. How to access the computers memory
  3. VisualBasic 6 (Write Proccess Memory) Dega (SMS) Emulator Set Rings by Sonic the hedgehog
  4. How to return the path to the windows directory.
  5. How to change the permission settings for a folder in Windows OS
  6. How to Swap Mouse Buttons
  7. How to determine free disk drive space over network?
  8. How to return the create date/time, last accessed date/time, last modified date/time of a given file
  9. How to find Windows NT registered user and organization
  10. How to return the number of CPUs in the system.

Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


No trackbacks yet.