home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Utilities / DVIM72-Mac 1.9.6 / source / App_partitions_total.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-14  |  736 b   |  33 lines  |  [TEXT/R*ch]

  1. #include <Processes.h>
  2.  
  3. long    App_partitions_total( void );
  4. Boolean TrapAvailable( short trapnum );
  5.  
  6. #ifndef GESTALT
  7. #define GESTALT            0xA1AD
  8. #endif
  9.  
  10. long    App_partitions_total( void )
  11. {
  12.     ProcessInfoRec            info;
  13.     ProcessSerialNumber        psn;
  14.     long                    total;
  15.     long                    response;
  16.     
  17.     if ( !TrapAvailable(GESTALT) ||
  18.         (Gestalt(gestaltOSAttr, &response) != noErr) ||
  19.         !(response & (1L << gestaltLaunchControl)) )
  20.         return 0L;
  21.     total = 0L;
  22.     info.processName = NIL;
  23.     info.processAppSpec = NIL;
  24.     info.processInfoLength = sizeof(ProcessInfoRec);
  25.     psn.highLongOfPSN = 0L;
  26.     psn.lowLongOfPSN = kNoProcess;
  27.     while ( GetNextProcess(&psn) == noErr )
  28.     {
  29.         if ( GetProcessInformation(&psn, &info) == noErr)
  30.             total += info.processSize;
  31.     }
  32.     return total;
  33. }