How to Set the Default Printer Programmatically in Windows 95

Last reviewed: July 1, 1996
Article ID: Q140560
The information in this article applies to:
  • Microsoft Windows Device Development Kit (DDK) for Windows 95

SUMMARY

To set the default printer programmatically under Windows 95, use the SetPrinter() Win32 API function.

Note that the SetPrinter() API call is a valid method, but it platform- dependent and should work only on Windows 95 (it does not work on Windows NT or on a 16-bit platform).

For additional information, please see the following article(s) in the Microsoft Knowledge Base:

   ARTICLE-ID: Q135387
   TITLE     : How to Get and Set the Default Printer in Windows

MORE INFORMATION

To set or change the default printer under Windows 95, call:

   SetPrinter(HANDLE hPrinter, DWORD dwLevel, LPBYTE lpbPrinter,
      DWORD dwCommand)

Obtain the hPrinter parameter from OpenPrinter() as a handle that identifies the desired printer. Set the dwLevel parameter to 5, and point lpbPrinter to the PRINTER_INFO_5 structure. Set the dwCommand parameter to 0. Fill out the PRINTER_INFO_5 structure appropriately making sure that the Attributes field has PRINTER_ATTRIBUTE_DEFAULT set.


Additional reference words: 4.00
KBCategory: kbenv kbhowto
KBSubcategory:



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: July 1, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.