|
-
Aug 17th, 2000, 09:35 PM
#1
Thread Starter
Member
Hi,
Is there a way of getting the amount of memory under Win9x/NT/2000?
Thanks in advance
-
Aug 17th, 2000, 11:13 PM
#2
Guru
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
-
Aug 17th, 2000, 11:38 PM
#3
New Member
it can be done
Hi,
You can use api call.
-
Aug 24th, 2000, 08:23 PM
#4
Thread Starter
Member
Thank you very much for the information. I really appreciate that.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|