Results 1 to 5 of 5

Thread: URGENT PLEASE! PLZ!

  1. #1

    Thread Starter
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    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

  2. #2
    Junior Member
    Join Date
    Jun 1999
    Location
    South Africa
    Posts
    22

    Post

    There is an API available to perform this check. - go and see the site VB API found as a partner site to this one.

  3. #3

    Thread Starter
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    Come on guys, you can do better!

    thks.
    Jefferson

  4. #4

    Thread Starter
    Registered User
    Join Date
    Apr 1999
    Location
    Brazil
    Posts
    144

    Post

    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?

  5. #5
    Guest

    Post

    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
  •  



Click Here to Expand Forum to Full Width