Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Advanced
Aug 5, 1997

Show Free Memory Under Win32

If you want to show your users the available memory on the machine, and you're moving from 16 bits to 32 bits, you'll find the API function GetFreeSystemResources has been dropped. You can still do it in VB4/32 and VB5, though. You need to declare the API function and this type in a module:
 
Declare Sub GlobalMemoryStatus Lib _
        "kernel32" (lpBuffer As _
        MEMORYSTATUS)

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
Fill the dwlength field with the MEMORYSTATUS type size. Long variables take four bytes, so the total size is 4*8=32 bytes:
 
Dim ms As MEMORYSTATUS

ms.dwLength = Len(ms)
GlobalMemoryStatus ms
MsgBox "Total physical memory:" & _
        ms.dwTotalPhys & vbCr _
        & "Available physical memory:" & _
        ms.dwAvailPhys & vbCr & _
        "Memory load:" & ms.dwMemoryLoad
You could also create a class to encapsulate this.
Luis Ferreira
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date