INF: Detecting Parallel Out-of-Paper Status
PSS ID Number: Q117867
Article last modified on 07-18-1994

3.10 3.50

WINDOWS NT


----------------------------------------------------------------------
The information in this article applies to:

 - Microsoft Win32 Software Development Kit (SDK) for Windows NT
   versions 3.1 and 3.5
----------------------------------------------------------------------

If you want to detect an out-of-paper condition in your application, open
the parallel port directly. If a write fails because the printer is out of
paper, GetLastError() returns ERROR_OUT_OF_PAPER. This is how the spooler
detects this condition. Note that the bytes written field is still valid.

The following code fragment demonstrates how you might structure your code
to detect an out-of-paper condition:

   for (i = 0; i < nBytesInFile; i += bytesWritten)
   {
      bytesToWrite = 4096;
      if (bytesToWrite > nBytesInFile - i)
      {
         bytesToWrite = nBytesInFile - i;
      }
      if (!WriteFile(hLpt, fileBuf+i, nBytesToWrite, &bytesWritten, NULL))
      {
         if (GetLastError() == ERROR_OUT_OF_PAPER)
         {
            // Do special out-of-paper pop up.
            // Break out of loop if no retry is wanted.
         }
         else
         {
            // Other error handling.
            // Break out of loop if no retry is wanted.
         }
      }
   }

Additional reference words: 3.10 3.50
KBCategory: Prg
KBSubcategory: BseMisc

=============================================================================

Copyright Microsoft Corporation 1994.
