CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: eVB memory available

  1. #1
    Join Date
    Aug 2002
    Posts
    5

    eVB memory available

    Does anyone know how to use the 'getmemorystatus' function in evb, I cannot get much help from the help files.

    I know I need to declare the function but am not sure how. I also know I need to create a structure to store the results in, I also do not know how to this.

    Any help would be most appreciated.

    alternatively, can anyone suggest any other way of finding out how much ram in remaining.

    Thanks

    Icarusbop

  2. #2
    Join Date
    Apr 2000
    Location
    Southampton, UK
    Posts
    329
    Can you post the declare as I don't have it, I am sure that we can work out the type declaration from that.
    TimCottee
    I know a little about a lot of things and a lot about very little.

    Brainbench MVP For Visual Basic
    http://www.brainbench.com

    MCP, MCSD, MCDBA, CPIM

  3. #3
    Join Date
    Aug 2002
    Posts
    5

    the declare line plus other code

    the example declare in the help file is listed as follows

    void GlobalMemoryStatus(LPMEMORYSTATUS lpBuffer );

    I have tried inserting a declare into the vb module as follows

    Declare Function GlobalMemoryStatus Lib "coredll.dll" ()

    but am missingthe nameof the memory structure between the two brackets, the help files say I need a memory status structure (not sure what this is I suspect it is more native to C than VB)

    the help files inform the following lines for setting up a structure


    typedef struct _MEMORYSTATUS {
    DWORD dwLength;
    DWORD dwMemoryLoad;
    DWORD dwTotalPhys;
    DWORD dwAvailPhys;
    DWORD dwTotalPageFile;
    DWORD dwAvailPageFile;
    DWORD dwTotalVirtual;
    DWORD dwAvailVirtual;
    } MEMORYSTATUS, *LPMEMORYSTATUS;

    none of which makes any sense to me : again I suspect it is C.

    I have no idea where or how to put the above code to get the thing running, i have no idea what the 'void' is at the top line. I am beginning to think you cannot run this function from VB, only from C.

    If you can help any more from this info - thanks very much.

    Icarusbop

  4. #4
    Join Date
    Apr 2002
    Posts
    388
    i have a little example:

    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 Form_Load()
      Dim mem As MEMORYSTATUS
      Dim txt As String
        GlobalMemoryStatus mem
     
        With mem
            txt = txt & "Speicher belegt in Prozent : " & Format$ _
                         (.dwMemoryLoad, "@@@@@@@@@@@") & vbCrLf
            txt = txt & vbCrLf
     
            txt = txt & "Totaler physischer Speicher: " & Format$ _
                         (.dwTotalPhys, "@@@@@@@@@@@") & vbCrLf
            txt = txt & "Davon noch frei            : " & Format$ _
                         (.dwAvailPhys, "@@@@@@@@@@@") & vbCrLf
            txt = txt & vbCrLf
     
            txt = txt & "Bytes in gepageten Dateien : " & Format$ _
                         (.dwTotalPageFile, "@@@@@@@@@@@") & vbCrLf
            txt = txt & "Davon noch frei            : " & Format$ _
                         (.dwAvailPageFile, "@@@@@@@@@@@") & vbCrLf
            txt = txt & vbCrLf
     
            txt = txt & "Totaler virtueller Speicher: " & Format$ _
                         (.dwTotalVirtual, "@@@@@@@@@@@") & vbCrLf
            txt = txt & "Davon noch frei:           : " & Format$ _
                         (.dwAvailVirtual, "@@@@@@@@@@@") & vbCrLf
        End With
     
        Label1.Caption = txt
    End Sub
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  5. #5
    Join Date
    Aug 2002
    Posts
    5
    Well the exmple you sent all looks good, but eVB will not accept it,

    firstly it complains about the memorystatus declararion ' reserved words are not allowed as a variable' or some such
    then it also tells me declares are not allowed in VB.

    The code looks fine, but again I suspect it is from a C example - or am I being completely dim?


    Ian (icarusbop)

  6. #6
    Join Date
    Apr 2002
    Posts
    388
    yes, it is an API call.

    I tested it in vb6 not in eVB (whatever it is).

    sorry, no other ideas
    mfg Ungi

    Music, music and VB. VB is like music: You never know how it is interpreted.

  7. #7
    Join Date
    Aug 2002
    Posts
    5
    UNGI:

    That was quick - in the meantime I gave it a go in VB6 and found it worked.

    eVB is embedded Visual basic - which is on the pocket PC not the normal PC.

    it seems the two are not as compatible as we first thought.

    Thanks for the help anyway.
    Ian

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)