home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / PRT_QUEU.ZIP / QUEUEMAN.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1988-10-25  |  3.6 KB  |  144 lines

  1. unit queueman;
  2. { a unit to allow manipulation of the print queue (DOS' Print.Com utility) }
  3. { Author : Bob Hodge, for Country Basket Software
  4.  (placed into Public Domain, 25-OCT-88) }
  5.  
  6. interface
  7.  
  8. uses DOS;
  9.  
  10. { note: the status word returned by these functions will have one of the
  11. following values }
  12. {
  13.     0    = Function successful
  14.     2    = File Not Found
  15.     3    = Path Not Found
  16.     4    = Too Many Open Files
  17.     5    = Access Denied
  18.     8    = Queue Full
  19.     9    = Busy
  20.   12    = Name Too Long
  21.   15    = Invalid Drive
  22. }
  23.  
  24. function QueueInstalled : boolean;
  25. { returns TRUE if print.com is installed; FALSE otherwise }
  26.  
  27. function SubmitFile( FileSpec : string): word;
  28. { Add the specified file to the queue.  FileSpec should contain NO global
  29. characters, but may contain drive and path info.  Returned word will
  30. conform to above comment. }
  31.  
  32. function CancelFile( FileSpec : string): word;
  33. { Remove the specified file from the queue.  Parms same as SubmitFile }
  34.  
  35. function KillQueue: word;
  36. { Removes ALL files currently on queue, aborts present print job. }
  37.  
  38. function QueuePointer : pointer;
  39. { This function allows access to the list of files currently on the queue,
  40. by returning the address of the beginning of the queue list.  It can be
  41. used as  " ^array[1..64] of char " (pointer to a 64-character array),
  42. with a filespec null-terminated within that array.  Each entry is
  43. immediately succeeded by the next 64-character filespec, and the final
  44. entry starts with a null.  See example code for illumination. }
  45.  
  46. procedure PauseQueue;
  47. { If you need to stop the background processing performed by print.com,
  48. this procedure will temporarily do that. }
  49.  
  50. procedure ContinueQueue;
  51. { Call this procedure to restart background processing.  May be called with
  52. no effect if PauseQueue has not been invoked. }
  53.  
  54. implementation
  55.  
  56. type
  57.     Packet =    record
  58.                     level : byte;
  59.                     AscPtr: pointer;
  60.                 end;
  61. var
  62.     qPaused    : boolean;        { TRUE if the print queue is currently paused }
  63.     regs        : registers;
  64.     SubPack    : Packet;
  65.  
  66. function QueueInstalled{ : boolean};
  67. begin
  68.     regs.ax := $0100;
  69.     intr($2F, regs);
  70.     if regs.al = $FF then
  71.         QueueInstalled := TRUE
  72.     ELSE
  73.         QueueInstalled := FALSE;
  74. end;
  75.  
  76. function SubmitFile{( FileSpec : string): word};
  77. begin
  78.     FileSpec[length(FileSpec)+1] := chr(0);
  79.     SubPack.level := 0;
  80.     SubPack.AscPtr := @FileSpec[1];            { skip the length byte }
  81.     regs.dx := ofs(SubPack);
  82.     regs.ds := seg(SubPack);
  83.     regs.ax := $0101;
  84.     intr($2F, regs);
  85.     if (regs.flags AND FCarry) <> 0 then
  86.         SubmitFile := regs.ax
  87.     ELSE
  88.         SubmitFile := 0;
  89. end;
  90.  
  91. function CancelFile{( FileSpec : string): word};
  92. begin
  93.     FileSpec[length(FileSpec)+1] := chr(0);
  94.     regs.dx := ofs(FileSpec[1]);
  95.     regs.ds := seg(FileSpec);
  96.     regs.ax := $0102;
  97.     intr($2F, regs);
  98.     if (regs.flags AND FCarry) <> 0 then
  99.         CancelFile := regs.ax
  100.     ELSE
  101.         CancelFile := 0;
  102. end;
  103.  
  104. function KillQueue: word;
  105. begin
  106.     regs.ax := $0103;
  107.     intr($2F, regs);
  108.     if (regs.flags AND FCarry) <> 0 then
  109.         KillQueue := regs.ax
  110.     ELSE
  111.         KillQueue := 0;
  112. end;
  113.  
  114. function QueuePointer{ : pointer};
  115. begin
  116.     regs.ax := $0104;        { pause and return status }
  117.     intr($2F, regs);
  118.     QueuePointer := ptr( regs.ds, regs.si);
  119.     if not qPaused then
  120.     begin
  121.         regs.ax := $0105;        { if we were not paused, release the queue }
  122.         intr($2F, regs);
  123.     end;
  124. end;
  125.  
  126. procedure PauseQueue;
  127. begin
  128.     regs.ax := $0104;        { pause and return status }
  129.     intr($2F, regs);
  130.     if (regs.flags AND FCarry) = 0 then
  131.         qPaused := TRUE;
  132. end;                            { no status return to caller }
  133.  
  134. procedure ContinueQueue;
  135. begin
  136.     regs.ax := $0105;
  137.     intr($2F, regs);
  138.     if (regs.flags AND FCarry) = 0 then
  139.         qPaused := FALSE;
  140. end;
  141.  
  142. begin            { automatic initialization }
  143.     qPaused := FALSE;
  144. end.