home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MEM428.ZIP / MEMAVL20.C < prev    next >
C/C++ Source or Header  |  1992-04-28  |  2KB  |  58 lines

  1. /****************************************************************************
  2.  
  3.     MemAvl20.C - Module to display several OS/2 2.0 Memory Statistics
  4.  
  5.     This module queries and reports the following OS/2 values:
  6.  
  7.     QSV_TOTPHYSMEM        total bytes of physical memory
  8.     QSV_TOTRESMEM        total bytes occupied by resident pages
  9.     QSV_TOTAVAILMEM        total bytes of virtual memory available
  10.  
  11.     Note that the 6.304 Toolkit On-line docs show these values as
  12.     being reported in pages.  It appears they are really byte
  13.     values (or else my PC is hiding a lot of memory<g>).
  14.  
  15.     history
  16.     04-28-92 ras - CR P920026, initial entry
  17.  
  18. ****************************************************************************/
  19. #define INCL_DOS
  20. #include <os2.h>            // OS/2 definitions
  21. #ifdef NULL                // Watcom definition different
  22.  #undef NULL                // so clear OS/2 version
  23. #endif
  24. #include <stdlib.h>            // standard functions
  25. #include <stdio.h>            // standard i/o
  26.  
  27. // start function
  28. int    main( )
  29.     
  30.   {    // define automatics
  31.     ULONG        qStatus;        // OS/2 status
  32.       ULONG        qValue[3];        // query values
  33.  
  34.     // ask OS/2 for physical memory count
  35.     qStatus = DosQuerySysInfo( QSV_TOTPHYSMEM,
  36.                    QSV_TOTAVAILMEM,
  37.                    &qValue[0],
  38.                    sizeof(qValue) );
  39.  
  40.     // check error
  41.     if ( qStatus != 0 )
  42.     {   // failed, report
  43.         printf( "\nDosQuerySysInfo failed, status of %ld", qStatus );
  44.         exit( qStatus );
  45.     }
  46.  
  47.     // display result
  48.     printf( "\nDosQuerySysInfo reports Physical memory: %ld", 
  49.         qValue[0] );
  50.     printf( "\n                        Resident memory: %ld", 
  51.         qValue[1] );
  52.     printf( "\n                           Avail memory: %ld", 
  53.         qValue[2] );
  54.  
  55.     // exit to caller
  56.     return( 0 );
  57.   }
  58.