Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Use of GlobalMemorySpace 1

Status
Not open for further replies.

aaaaaaaaaaaa

Programmer
Aug 4, 2001
25
IN
I have tried to use this api(GlobalMemorySpace)..
to know the information about the system....
Can Any one help me out in using this api..
 
Hi,

Don't you mean GlobalMemoryStatus (for finding out RAM, virtual memory, etc.)? Because I looked a long time for this function, but I couldn't find it anywhere...

LuCkY
 
Yes i mean that only(ram,virtual memory,physical memory..etc etc).....
If you have done this....then please give the example how u have done this...
Since when i am trying this it is giving error..
 
Here is the code for using the GlobalMemoryStatus . . .

Code:
Option Explicit
Private Declare Sub GlobalMemoryStatus Lib "kernel32" (lpBuffer As MEMORYSTATUS)
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 Sub Command1_Click()

   Dim udtMemeStat As MEMORYSTATUS
   Call GlobalMemoryStatus(udtMemeStat)
   

End Sub


The UDT will return multiple values . . . they are as follows . . .

Code:
dwLength        = Sizeof the memory status data UDT
dwMemoryLoad    = Percent of memory in use.
dwTotalPhys     = Total bytes of physical mem
dwAvailPhys     = Total bytes of physical mem in use.
dwTotalPageFile = Bytes of paging file (i.e. swap file)
dwAvailPageFile = Free space in paging file.
dwTotalVirtual  = User bytes of address space
dwAvailVirtual  = Free User bytes.


There are alot of other memory function/APIs that I have used in the past . . . is this the one that you were asking about? - Jeff Marler B-)
 
Thanks jmarler for your information....
i have tried but it is not giving the correct answer
 
What answer is it giving you? List the values that you received and then list your machine specs. Also, if you could, list your OS. On my machine, this API did give the correct results. - Jeff Marler B-)
 
I am using Win-2000..........
my hard-disk capacity is 4 Gb
Total bytes of physical mem and Total bytes of physical mem in use.
is not correct????


 
ok.........so can you tell in bit details...about this API...Actually one of friend has use this API in VC++ for retriving the Hard disk Capacity....He has recommended to use this...
 
Why don't u simply use the GetDiskFreeSpace command for getting the HD-Capacity like I said in the other thread?

Private 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

Private Sub Form_Load()
Dim Sectors As Long, Bytes As Long, FreeC As Long, TotalC As Long, Total As Long, Freeb As Long

GetDiskFreeSpace "C:\", Sectors, Bytes, FreeC, TotalC

MsgBox "Total space at C: is " & (TotalC * Sectors * Bytes / 1024 / 1024) & " MB and available is " & (FreeC * Sectors * Bytes / 1024 / 1024) & " MB"
End Sub
 
Yes, if you were after harddisk sapce, do what Lucky suggests. The GlobalmemoryStatus will give you the size of the swap file which is on the Harddrive, but it will not give you the entire hardrive. - Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top