home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c070 / 4.ddi / TOOLS.4 / TCTSRC1.EXE / ISCURPRC.C < prev    next >
Encoding:
C/C++ Source or Header  |  1989-03-31  |  1.6 KB  |  58 lines

  1. /**
  2. *
  3. * Name        iscurprc -- Return or set PSP address of currently
  4. *                executing process.
  5. *
  6. * Synopsis    oldproc = iscurprc(option,newproc);
  7. *
  8. *        unsigned oldproc  Segment address of PSP of currently
  9. *                  executing process beforehand.
  10. *        int option      IS_SETPROC to change the currently
  11. *                  executing process, or
  12. *                  IS_RETPROC to merely report it.
  13. *        unsigned newproc  If option is IS_SETPROC, newproc
  14. *                  is the PSP address of the new
  15. *                  currently executing process.
  16. *
  17. * Description    This function returns (and possibly changes) DOS's
  18. *        record of the program segment prefix (PSP) of the
  19. *        currently executing process.
  20. *
  21. * Returns    oldproc       Segment address of PSP of currently
  22. *                  executing process before the call.
  23. *
  24. * Version    6.00 (C)Copyright Blaise Computing Inc. 1987,1989
  25. *
  26. **/
  27.  
  28. #include <dos.h>
  29.  
  30. #include <bintrupt.h>
  31.  
  32. unsigned iscurprc(option,newproc)
  33. int     option;
  34. unsigned newproc;
  35. {
  36.     unsigned   result;
  37.     union REGS regs;
  38.  
  39.     /* DOS function 0x62 (Return PSP) is available (and documented)   */
  40.     /* for DOS versions 3.00 and later.  Function 0x51 is available,  */
  41.     /* but not documented, for all versions of DOS, so prefer          */
  42.     /* function 0x62 when it is available.                  */
  43.  
  44.     regs.h.ah = (unsigned char) ((utdosmajor < 3) ? 0x51 : 0x62);
  45.     intdos(®s,®s);
  46.  
  47.     result = regs.x.bx;
  48.  
  49.     if (option == IS_SETPROC)
  50.     {
  51.     regs.h.ah = 0x50;     /* DOS function 0x50:  Set current PSP  */
  52.     regs.x.bx = newproc;  /*  (an undocumented function).          */
  53.     intdos(®s,®s);
  54.     }
  55.  
  56.     return result;
  57. }
  58.