[comp.sys.ibm.pc.misc] Printer status from Turbo C

duvalj@bionette.cgrb.orst.edu (Joe Duval - Entomology) (08/07/90)

Hi, 
I need a function that will tell me whether or not a printer is online.
It should be able to handle any possible port.  Can I just call INT17 and
get the status from that?  Will it work for any port?  How do I specify the
port?

Thanks for your help
-Joe

--
Joe Duval		duvalj@bionette.cgrb.orst.edu
Looking for 62-64 Chevy Nova body parts.  I've got a 63 Nova SS forsale.

dgil@pa.reuter.COM (Dave Gillett) (08/08/90)

In <19721@orstcs.CS.ORST.EDU> duvalj@bionette.cgrb.orst.edu (Joe Duval - Entomology) writes:
>I need a function that will tell me whether or not a printer is online.
>It should be able to handle any possible port.  Can I just call INT17 and
>get the status from that?  Will it work for any port?  How do I specify the
>port?

INT 17H is the way to go.  The "printer number" goes in DX.  (PRN: is printer
number 0.  Why do I have this nagging suspicion that 0=LPT1, 1=LPT2, etc.?  It
feels right, but I don't have anything at hand to prove it....)  AH needs to be
02H going in, and contains the status byte on exit.  In my code, I consider the
printer to be unavailable if bit 10H (Printer Selected) is off, or if either bit
20H (Out of Paper) or 08H (I/O Error) is on, and ignore all other bits.

Note:  DOS does an acceptible job of faking this service for LPT ports that are
redirected to COM ports, so unless you want to provide XON/XOFF for serial 
printers, INT 17H is all you need.
                                                 Dave