PRODUCT : Borland C++ NUMBER : 1546 VERSION : 3.x OS : DOS DATE : October 25, 1993 PAGE : 1/2 TITLE : How to check printer status /* * Program to demonstrate checking the parallel ports to see if * it is ready to print. Some other info about the printer is * shown in the process. If you check the port in this way, * you won't have to wait for a timeout error when you try to * write to the printer and fail. */ #include #include #include /* these are various single bits in the status byte returned * from the printer. */ #define TIMEOUT 0x01 // bits 1 and 2 are not used. #define PRERROR 0x08 #define ONLINE 0x10 #define NOPAPER 0x20 #define ACKNOWL 0x40 #define NOTBUSY 0x80 void ShowStatus( unsigned printerID ); main() { int i; for (i=0; i<3; ++i) ShowStatus(i); return 0; } void ShowStatus(unsigned printerID) { /* pointer to BIOS data area which has port addresses of * printers */ static unsigned far *biosdata = (unsigned far *) MK_FP(0x0040,0x0008); unsigned char status; printf("\nPrinter Port LPT%d:\n",printerID+1); PRODUCT : Borland C++ NUMBER : 1546 VERSION : 3.x OS : DOS DATE : October 25, 1993 PAGE : 2/2 TITLE : How to check printer status /* the port address is set to 0 if the printer is not * installed */ if (*(biosdata+printerID)==0) { printf("Not Installed\n"); return; } /* we'll use interrupt 0x17, function 1 (Initialize Printer) * to check the status of the printer. */ status = biosprint(1,0,printerID); /* display some info about the printer (optional) */ if (status & TIMEOUT) printf("Timeout\t"); else printf("No Timeout\t"); if (status & PRERROR) printf("Error\t"); else printf("No Error\t"); if (status & ONLINE) printf("Online\t"); else printf("Not Online\t"); if (status & NOPAPER) printf("\nOut of Paper\t"); else printf("\nHas Paper\t"); if (status & ACKNOWL) printf("No Acknowledge\t"); else printf("Acknowledge\t"); if (status & NOTBUSY) printf("Not Busy\n"); else printf("Busy\n"); /* ONLINE and NOTBUSY must both be ON for the printer to be * OK to print to. */ if ((status & (ONLINE|NOTBUSY)) == (ONLINE|NOTBUSY)) printf("READY to Print\n"); else printf("NOT READY to Print\n"); } DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.