home *** CD-ROM | disk | FTP | other *** search
- unit queueman;
- { a unit to allow manipulation of the print queue (DOS' Print.Com utility) }
- { Author : Bob Hodge, for Country Basket Software
- (placed into Public Domain, 25-OCT-88) }
-
- interface
-
- uses DOS;
-
- { note: the status word returned by these functions will have one of the
- following values }
- {
- 0 = Function successful
- 2 = File Not Found
- 3 = Path Not Found
- 4 = Too Many Open Files
- 5 = Access Denied
- 8 = Queue Full
- 9 = Busy
- 12 = Name Too Long
- 15 = Invalid Drive
- }
-
- function QueueInstalled : boolean;
- { returns TRUE if print.com is installed; FALSE otherwise }
-
- function SubmitFile( FileSpec : string): word;
- { Add the specified file to the queue. FileSpec should contain NO global
- characters, but may contain drive and path info. Returned word will
- conform to above comment. }
-
- function CancelFile( FileSpec : string): word;
- { Remove the specified file from the queue. Parms same as SubmitFile }
-
- function KillQueue: word;
- { Removes ALL files currently on queue, aborts present print job. }
-
- function QueuePointer : pointer;
- { This function allows access to the list of files currently on the queue,
- by returning the address of the beginning of the queue list. It can be
- used as " ^array[1..64] of char " (pointer to a 64-character array),
- with a filespec null-terminated within that array. Each entry is
- immediately succeeded by the next 64-character filespec, and the final
- entry starts with a null. See example code for illumination. }
-
- procedure PauseQueue;
- { If you need to stop the background processing performed by print.com,
- this procedure will temporarily do that. }
-
- procedure ContinueQueue;
- { Call this procedure to restart background processing. May be called with
- no effect if PauseQueue has not been invoked. }
-
- implementation
-
- type
- Packet = record
- level : byte;
- AscPtr: pointer;
- end;
- var
- qPaused : boolean; { TRUE if the print queue is currently paused }
- regs : registers;
- SubPack : Packet;
-
- function QueueInstalled{ : boolean};
- begin
- regs.ax := $0100;
- intr($2F, regs);
- if regs.al = $FF then
- QueueInstalled := TRUE
- ELSE
- QueueInstalled := FALSE;
- end;
-
- function SubmitFile{( FileSpec : string): word};
- begin
- FileSpec[length(FileSpec)+1] := chr(0);
- SubPack.level := 0;
- SubPack.AscPtr := @FileSpec[1]; { skip the length byte }
- regs.dx := ofs(SubPack);
- regs.ds := seg(SubPack);
- regs.ax := $0101;
- intr($2F, regs);
- if (regs.flags AND FCarry) <> 0 then
- SubmitFile := regs.ax
- ELSE
- SubmitFile := 0;
- end;
-
- function CancelFile{( FileSpec : string): word};
- begin
- FileSpec[length(FileSpec)+1] := chr(0);
- regs.dx := ofs(FileSpec[1]);
- regs.ds := seg(FileSpec);
- regs.ax := $0102;
- intr($2F, regs);
- if (regs.flags AND FCarry) <> 0 then
- CancelFile := regs.ax
- ELSE
- CancelFile := 0;
- end;
-
- function KillQueue: word;
- begin
- regs.ax := $0103;
- intr($2F, regs);
- if (regs.flags AND FCarry) <> 0 then
- KillQueue := regs.ax
- ELSE
- KillQueue := 0;
- end;
-
- function QueuePointer{ : pointer};
- begin
- regs.ax := $0104; { pause and return status }
- intr($2F, regs);
- QueuePointer := ptr( regs.ds, regs.si);
- if not qPaused then
- begin
- regs.ax := $0105; { if we were not paused, release the queue }
- intr($2F, regs);
- end;
- end;
-
- procedure PauseQueue;
- begin
- regs.ax := $0104; { pause and return status }
- intr($2F, regs);
- if (regs.flags AND FCarry) = 0 then
- qPaused := TRUE;
- end; { no status return to caller }
-
- procedure ContinueQueue;
- begin
- regs.ax := $0105;
- intr($2F, regs);
- if (regs.flags AND FCarry) = 0 then
- qPaused := FALSE;
- end;
-
- begin { automatic initialization }
- qPaused := FALSE;
- end.