How to Check Available Windows System Resources

ID: Q111508


The information in this article applies to:
  • Microsoft Visual FoxPro for Windows, version 3.0
  • Microsoft FoxPro for Windows, versions 2.5, 2.5a, 2.5b


SUMMARY

The code sample below demonstrates how FOXTOOLS.FLL can be used to check the available Windows system resources from within FoxPro for Windows or a FoxPro for Windows application.


MORE INFORMATION

NOTE: This code only works under Microsoft Windows versions 3.x (16-bit Windows). Under Windows NT or Windows 95, it causes the following error message:

Entry point GetFreeSystemResources not found.
For more information about how to check available Windows system resources under Windows NT or Windows 95, see the following article in the Microsoft Knowledge Base:
Q146424 PRB: "Entry Point GetFreeSystemResources Not Found" Error
FOXTOOLS.FLL is a FoxPro application programming interface (API) library that allows FoxPro programs to call many Windows dynamic-link library (DLL) functions. The FOXTOOLS.WRI document explains how to use FOXTOOLS.FLL. Both files are located in the GOODIES\FOXTOOLS subdirectory of the main FoxPro for Windows directory.

The GetFreeSystemResources() function returns an integer representing the percentage of unused system, USER, or GDI resources. This function is part of the Microsoft Windows API. This function accepts the following parameters:

   UINT GetFreeSystemResources(fuSysResource)

   UINT fuSysResource      /* Type of resource to check */  
There are three resource types that can be checked:

  • GSFR_SYSTEMRESOURCES: Returns the percentage of free space for system resources. This is the same as the value found in the About box on the Program Manager Help menu. This number represents the lower of the following two values. (Value = 0.)


  • GSFR_GDIRESOURCES: Returns the percentage of free space for GDI resources. GDI resources include device-context handles, brushes, pens, regions, fonts, and bitmaps. (Value = 1.)


  • GSFR_USERRESOURCES: Returns the percentage of free space for USER resources. These resources include window and menu handles. (Value = 2.)

    
       * Program to check Windows system resources
    
       * Establish constants
       #DEFINE sysreso 0
       #DEFINE gdireso 1
       #DEFINE userreso 2
    
       * Load the FOXTOOLS.FLL library
       SET LIBRARY TO SYS(2004) + "FOXTOOLS.FLL" ADDITIVE
    
       * Call RegFN() to register the GetFreeSystemResources() function
       getsysres = RegFn("GetFreeSystemResources", "I","I")
    
       * If RegFn() returned a value that is greater than -1, it can be
       * assumed that the function was successfully registered.
       IF getsysres > -1
          * CallFn() is used to call the GetFreeSystemResources() function
          * with the desired parameter. The constant sysreso is used here
          * to return the percentage of free resources. CallFn() could also
          * be used with the gdireso or userreso constants defined above to
          * return the percentage of free GDI or USER resources.
          x = CallFn(getsysres, sysreso)
          WAIT WINDOW "Current System Resources are:"+STR(x,3,0)+"%"
       ENDIF
    
       * Unload FOXTOOLS.FLL from memory
    
       RELEASE LIBRARY SYS(2004)+ "FOXTOOLS.FLL" 


REFERENCES

Microsoft FoxPro for Windows FOXTOOLS.WRI

Microsoft Windows Software Development Kit "Programmer's Reference, Volume 2: Functions," version 3.1

Additional query words: VFoxWin FoxWin 2.50 api fll fox tools kbvfp300


Keywords          : kbcode FxprgFoxtools 
Version           : 2.50 2.50a 2.50b 3.00
Platform          : WINDOWS 
Issue type        : 


Last Reviewed: August 3, 1999
© 1999 Microsoft Corporation. All rights reserved. Terms of Use.