Reprinted:
Globalmemorystatus, Win32 API function.
This function is used to obtain available physical and virtual memory information. The function is defined:
Void globalmemorystatus
(
Lpmemorystatus lpbuffer
);
This function has no return value. The parameter is a pointer to the structure named memorystatus. The returned information of the function is stored in the memorystatus structure.
This function is used to replace the getfreespace function that supports 16-bit applications.
The application should call this function before applying for memory to prevent other programs from being affected.
The return value of this function is dynamic and may return the same value.
About the memorystatus structure:
Organization definition:
Typedef struct _ memorystatus
{// MST
DWORD dwlength; // sizeof (memorystatus)
DWORD dwmemoryload; // percent of memory in use
DWORD dwtotalphys; // bytes of physical memory
DWORD dwavailphys; // free physical memory bytes
DWORD dwtotalpagefile; // bytes of paging file
DWORD dwavailpagefile; // free bytes of paging file
DWORD dwtotalvirtual; // user bytes of address space
DWORD dwavailvirtual; // free user bytes
} Memorystatus, * lpmemorystatus;
Structure member description:
DwlengthThe size of the memorystatus structure, which is obtained by using the sizeof () function before calling the globalmemorystatus function,
The version used to check the structure of the function.
DwmemoryloadReturns a value ranging from 0 ~ Value between 100 to indicate the current system memory usage.
DwtotalphysReturns the total physical memory size, in bytes.
DwavailphysReturns the available physical memory in bytes.
DwtotalpagefileDisplays the number of bytes that can exist in the page file. Note that this value does not indicate the actual physical size of the page file on the disk.
DwavailpagefileReturns the size of Available page files, in bytes.
DwtotalvirtualReturns all available virtual address spaces in the user mode of the calling process, in bytes.
DwavailvirtualReturns the free virtual address space of the user mode part of the calling process, in bytes.
Memorystatus structure,
The structure is defined as follows:
Memorystatus struct
Dwlength DWORD; length of the current structure
Dwmemoryload DWORD; percentage of memory in use
Dwtotalphys DWORD; total physical memory
Dwavailphys DWORD; available physical memory
Dwtotalpagefile DWORD; Total swap file size
Dwavailpagefile DWORD; the size of the free part in the SWAp File
Dwtotalvirtual DWORD; available address space of the user
Dwavailvirtual DWORD; the current idle address space
Memorystatus ends
This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/sunky/archive/2008/07/15/2654254.aspx