Results 1 to 4 of 4

Thread: Physical RAM

  1. #1

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    34

    Unhappy

    Hi,

    Is there a way of getting the amount of memory under Win9x/NT/2000?

    Thanks in advance
    Regards

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Why, of course there is!

    Create a new standard project and put a CommandButton (Command1) on the form.
    Then, use this code:
    Code:
    Option Explicit
    
    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 Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
    
    Private Sub Command1_Click()
        Dim MS As MEMORYSTATUS ' Declare MEMORYSTATUS structure
        Dim sMsg As String
        
        MS.dwLength = Len(MS) ' Determine the size of the structure (required for compatibility)
        Call GlobalMemoryStatus(MS) ' Fill the structure with information
        
        ' Now, MS.dwAvailPhys is the amount of available RAM (in bytes)
        ' and MB.dwTotalPhys is the amount of total RAM (in bytes).
        ' To determine the amount in megabytes you need to divide by 2^20 (1048576).
        ' You can use CLng to remove the remainder.
        
        sMsg = "You have " & CLng(MS.dwAvailPhys / 2 ^ 20) & " megabytes of RAM available, out" & vbCrLf
        sMsg = sMsg & "of " & CLng(MS.dwTotalPhys / 2 ^ 20) & " bytes of RAM. ("
        ' Determine percentage:
        sMsg = sMsg & CLng(MS.dwAvailPhys / MS.dwTotalPhys * 100)
        sMsg = sMsg & "% free)"
        
        Call MsgBox(sMsg, vbExclamation)
    End Sub

  3. #3
    New Member
    Join Date
    Aug 2000
    Posts
    8

    Smile it can be done

    Hi,
    You can use api call.

  4. #4

    Thread Starter
    Member
    Join Date
    Jan 2000
    Location
    Canada
    Posts
    34

    Smile

    Thank you very much for the information. I really appreciate that.
    Regards

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width