How To Change the Work Offline Status of a Printer

Last reviewed: December 9, 1996
Article ID: Q160456
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) for Windows 95, version 4.00 on the following platform: Win95

SUMMARY

Printers in Windows 95 can be set to a state called Work Offline in which print jobs are spooled and held. The print jobs are not despooled until Work Offline is deactivated. The Work Offline state is reflected by the Work Offline item in the Printer's File menu that indicates the condition with a check mark.

MORE INFORMATION

While the Work Offline state is reflected by the condition of the PRINTER_STATUS_USER_INTERVENTION bit in a PRINTER_INFO structure's Status member, it is actually an attribute of the printer. As such, it is indicated and controlled by the PRINTER_ATTRIBUTE_WORK_OFFLINE bit of a PRINTER_INFO_2 structure's Attribute member. The Attribute member is a bitfield of Attribute bits for that printer. See the Win32 SDK online documents for a complete description of this structure member and its values.

Note that the Work Offline state of a printer in Windows is distinctly different from a printer being Off-line. The difference is that the PRINTER_ATTRIBUTE_WORK_OFFLINE attribute applies to a Window's Print Queue and effects how the queue behaves, while the Off-line status of a physical printer device is set on the device. The Off-line status of a physical printer can be determined from the Status members of either a PRINTER_INFO or JOB_INFO structure. See the Printer and Print Job status article in the REFERENCE section in this article for details.

Attribute information for a printer can be read and written by the GetPrinter and SetPrinter API functions. To determine if a printer is currently in the Work Offline state, perform a logical AND of the predefined constant PRINTER_ATTRIBUTE_WORK_OFFLINE and the Attribute member of a PRINTER_INFO_2 structure with the C language "&" operator. To change the Work Offline state of a printer, follow these steps:

  1. Retrieve a PRINTER_INFO_2 structure for the printer by calling the GetPrinter function multiple times.

  2. Change the PRINTER_ATTRIBUTE_WORK_OFFLINE bit of a PRINTER_INFO_2 structure's Attribute member. The following sample code illustrates how to clear or set a bit of this bitfield properly:

    if (pi2->Attributes & PRINTER_ATTRIBUTE_WORK_OFFLINE) {

           DWORD   dwStatusMask;
    
           /* set, so clear the bit */
           dwStatusMask = ~(DWORD)(PRINTER_ATTRIBUTE_WORK_OFFLINE);
           pi2->Attributes = pi2->Attributes & dwStatusMask;
       }
       else
       {
           /* not set, so set it */
           pi2->Attributes = pi2->Attributes | PRINTER_ATTRIBUTE_WORK_OFFLINE;
       }
    
    

  3. Call the SetPrinter function to set the state of the printer by passing the modified structure.

Note that the PRINTER_ATTRIBUTE_WORK_OFFLINE attribute is not supported for printers in Windows NT.

REFERENCES

For more information on calling Win32 Spooler API functions, please see the following articles in the Microsoft Knowledge Base:

   ARTICLE-ID: Q158828
   TITLE     : How To Call Win32 Spooler Enumeration APIs Properly

   ARTICLE-ID: Q140285
   TITLE     : How to Modify Printer Settings by Using SetPrinter

   ARTICLE-ID: Q160129
   TITLE     : How To Get the Status of a Printer and a Print Job


KBCategory: kbprint kbhowto
KBSubcategory: GdiPrn GdiSpool
Additional reference words: 4.00 KbDSI GdiSpool Printer Properties



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.

Last reviewed: December 9, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.