Kbase 17277: How to Call WIN32 API Function: GlobalMemoryStatus
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  10/05/1998 |
|
How to Call WIN32 API Function: GlobalMemoryStatus
DISCLAIMER:
===========
The code example in this knowledgebase is for informational purposes
only. If you have specific questions about which API calls would be
best suited to your design goals, please consult your Microsoft
documentation.
INTRODUCTION:
=============
The following sample code shows how to call the Win32 API function
called GlobalMemoryStatus. This function retrieves information about
the current available memory. The function returns information about
both physical and virtual memory.
This code has been tested on Windows NT 4.0 Workstation only.
DEFINE VARIABLE intMemoryLoad AS INTEGER NO-UNDO.
DEFINE VARIABLE intTotalPhys AS INTEGER NO-UNDO.
DEFINE VARIABLE intAvailPhys AS INTEGER NO-UNDO.
DEFINE VARIABLE intTotalPageFile AS INTEGER NO-UNDO.
DEFINE VARIABLE intAvailPageFile AS INTEGER NO-UNDO.
DEFINE VARIABLE intTotalVirtual AS INTEGER NO-UNDO.
DEFINE VARIABLE intAvailVirtual AS INTEGER NO-UNDO.
DEFINE VARIABLE ptrToMemStatStruct AS MEMPTR NO-UNDO.
PROCEDURE GlobalMemoryStatus EXTERNAL "KERNEL32.DLL":
DEFINE INPUT PARAMETER ptrToMemStatStruct AS MEMPTR.
END PROCEDURE.
SET-SIZE(ptrToMemStatStruct) = 32.
PUT-LONG(ptrToMemStatStruct,1) = 32.
RUN GlobalMemoryStatus (INPUT ptrToMemStatStruct).
ASSIGN intMemoryLoad = GET-LONG(ptrToMemStatStruct,05)
intTotalPhys = GET-LONG(ptrToMemStatStruct,09)
intAvailPhys = GET-LONG(ptrToMemStatStruct,13)
intTotalPageFile = GET-LONG(ptrToMemStatStruct,17)
intAvailPageFile = GET-LONG(ptrToMemStatStruct,21)
intTotalVirtual = GET-LONG(ptrToMemStatStruct,25)
intAvailVirtual = GET-LONG(ptrToMemStatStruct,29).
MESSAGE intMemoryLoad SKIP
intTotalPhys SKIP
intAvailPhys SKIP
intTotalPageFile SKIP
intAvailPageFile SKIP
intTotalVirtual SKIP
intAvailVirtual VIEW-AS ALERT-BOX.
SET-SIZE(ptrToMemStatStruct) = 0.
Progress Software Technical Support Note # 17277