KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q23867: Sending 1Ah to a Printer Requires Setting "Raw" Mode

Article: Q23867
Product(s): See article
Version(s): 3.00 4.00 5.00 5.10 6.00 6.00a
Operating System(s): MS-DOS
Keyword(s): ENDUSER | | mspl13_c
Last Modified: 4-FEB-1991

Problem:

I am trying to output a graphics file to a printer. I have opened the
printer as a binary file, but the output stops every time I try to
output hexadecimal character 1A. I assumed that anything could be
output to a binary file.

Response:

If you open a device, such as PRN, as a binary file using fopen() or
open(), the device will not translate carriage return/line feed
combinations. However, DOS will continue to interpret CTRL+Z (1Ah) as
an end-of-file character.

You must use interrupt 21h function 44h to set the raw-mode bit for
the device to disable checking for CTRL+Z characters. This way, all
characters will be allowed to pass.

The following example was taken from page 351 of "Advanced MS-DOS
Programming," which gives an assembly language program example for
setting raw mode.

Sample Code
-----------

void setrawmode(void)
{
   union REGS inregs, outregs;

   inregs.x.ax = 0x4400;
   inregs.x.bx = 0x04;         /* specify the printer */
   int86(0x21, &inregs, &outregs);

   outregs.h.dh = 0x00;
   outregs.h.dl = 0x20;        /* set raw mode bit */
   outregs.x.ax = 0x4401;
   int86(0x21, &outregs, &inregs);
}

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.