|
-
Feb 16th, 2000, 08:08 PM
#1
Thread Starter
Registered User
To finish a program 100% I just need display how many RAM has on the machine.
This IS VERY IMPORTANT TO ME!
Thanks in advance.
Jefferson
-
Feb 16th, 2000, 08:29 PM
#2
Junior Member
There is an API available to perform this check. - go and see the site VB API found as a partner site to this one.
-
Feb 16th, 2000, 09:06 PM
#3
Thread Starter
Registered User
Come on guys, you can do better! 
thks.
Jefferson
-
Feb 17th, 2000, 09:48 AM
#4
Thread Starter
Registered User
Well, if some one access this page 'll find the code that I MAKE, some one in wwww.vbchat.com give the API GetDiskFreeSpaceEx and then I make this:

'
'If your app 'll run under 95 you'll need
'extra code.
'
Declare Function GetDiskFreeSpaceEx Lib "kernel32" Alias _
"GetDiskFreeSpaceExA" (ByVal lpRootPathName As String, _
lpFreeBytesAvailableToCaller As Currency, _
lpTotalNumberOfBytes As Currency, _
lpTotalNumberOfFreeBytes As Currency) As Long
Declare Function GetDiskFreeSpace Lib "kernel32" Alias _
"GetDiskFreeSpaceA" (ByVal lpRootPathName As String, _
lpSectorsPerCluster As Long, _
lpBytesPerSector As Long, _
lpNumberOfFreeClusters As Long, _
lpTtoalNumberOfClusters As Long) As Long
Public Function GetFreeSpace(ByVal pDrive As String, Optional ByRef nTotal As Double) As String
If IsWin95() Then
Dim SectorsCluster As Long
Dim BytesSector As Long
Dim FreeClusters As Long
Dim TotalClusters As Long
If Len(pDrive) = 2 Then pDrive = pDrive & "\"
Call GetDiskFreeSpace(pDrive, _
SectorsCluster, _
BytesSector, _
FreeClusters, _
TotalClusters)
nTotal = Round((((SectorsCluster * FreeClusters) * BytesSector) / 1024) / 1024, 0)
GetFreeSpace = nTotal & " MB"
Else
Dim curTotalBytes As Currency
Dim curFreeBytesToCaller As Currency
Dim curTotalFreeBytes As Currency
Call GetDiskFreeSpaceEx(pDrive, curFreeBytesToCaller, curTotalBytes, curTotalFreeBytes)
nTotal = Round(((curTotalFreeBytes * 10000) / 1024) / 1024, 0)
'GetFreeSpace = Format$(curTotalFreeBytes * 10000, "###,###,###,##0") & " Bytes"
GetFreeSpace = nTotal & " MB"
End If
End Function
Private Function Round(nValue As Double, nDigits As Integer) As Double
Round = Int(nValue * (10 ^ nDigits) + 0.5) / (10 ^ nDigits)
End Function
I hope this could help someone else.
Jefferson
_________________________________
How is your future?
-
Feb 17th, 2000, 11:06 AM
#5
Paste this into a modul :
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
Const fmt As String = "###,###,###,###"
Const skb As String = " Kbyte"
Const nkb As Long = 1024
Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
Function GetRAM() As String
Dim MS As MEMORYSTATUS
MS.dwLength = Len(MS)
GlobalMemoryStatus MS
GetRAM = Format$(MS.dwTotalPhys / nkb, fmt) & skb
End Function
Function GetAviableRam() As String
Dim MS As MEMORYSTATUS
MS.dwLength = Len(MS)
GlobalMemoryStatus MS
tmp = MS.dwTotalPhys / 100
a = MS.dwAvailPhys / tmp
a = 100 - a
a = Int(a)
GetAvRam = Format$(MS.dwAvailPhys / nkb, fmt) & skb & " [" & a & " % used]"
End Function
Function GetPageFile() As String
Dim MS As MEMORYSTATUS
MS.dwLength = Len(MS)
GlobalMemoryStatus MS
GetPF = Format$(MS.dwTotalPageFile / nkb, fmt) & skb
End Function
Function GetAviablePageFile() As String
Dim MS As MEMORYSTATUS
MS.dwLength = Len(MS)
GlobalMemoryStatus MS
tmp = MS.dwTotalPageFile / 100
a = MS.dwAvailPageFile / tmp
a = 100 - a
GetFreePF = Format$(MS.dwAvailPageFile / nkb, fmt) & skb & " [" & Format$(a, fmt) & " % used]"
End Function
---------------------------
hope that helps....
[This message has been edited by taLON (edited 02-17-2000).]
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
|