home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / dtx9203 / borhot / keep.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-25  |  1.3 KB  |  40 lines

  1. /* ------------------------------------------------------ */
  2. /*                       KEEP.C                           */
  3. /*      Determining the Size of a Program at Runtime      */
  4. /*              (c) 1991 Borland International            */
  5. /*                   All rights reserved.                 */
  6. /* ------------------------------------------------------ */
  7. /*            veröffentlicht in DOS toolbox 3'92          */
  8. /* ------------------------------------------------------ */
  9.  
  10. #include <dos.h>   // for MK_FP, _psp and keep()
  11.  
  12.                    // Only 5 pertinent bytes are detailed
  13. typedef struct {
  14.   unsigned char mcb_type;
  15.                    // 5Ah if last block in chain, else 4Dh
  16.   unsigned owner;  // 0000 if free, 0008 if DOS
  17.   unsigned size;   // size of MCB in paragraphs
  18. } MCB;
  19.  
  20. /* ------------------------------------------------------ */
  21.  
  22. int main (void)
  23. {
  24.   MCB far *program_psp;
  25.  
  26.   // Install TSR
  27.   // Make a pointer to the controlling MCB and extract
  28.   // the size of the block from it.
  29.  
  30.   // Make pointer to MCB header
  31.   // then terminate & stay resident
  32.   program_psp = (MCB far*) MK_FP(_psp-1, 0);
  33.   keep (0, program_psp->size);
  34.  
  35.   return 0;
  36. }
  37. /* ------------------------------------------------------ */
  38. /*                 Ende von  KEEP.C                       */
  39.  
  40.