How to Add a Network Printer ConnectionLast reviewed: August 7, 1996Article ID: Q147202 |
The information in this article applies to:
SUMMARYWhen writing a Win32 application that installs a network printer connection, you must take into consideration differences in printing if the application will be run under both Windows 95 and Windows NT. One important difference is that Windows NT may download appropriate drivers from the print server while under Windows 95, you need to add the printer driver files to the system with the AddPrinterDriver() function.
MORE INFORMATIONThis process should take two separate code paths depending on whether you are running Windows NT or Windows 95. In Windows 95, you will want to add the printer driver with AddPrinterDriver() and add the printer connection with AddPrinter(). In Windows NT, you need only call the AddPrinterConnection() function.
Steps for Adding a Printer Connection in Windows 95
PRINTER_INFO_2 pi2; DRIVER_INFO_2 di2; HANDLE hPrinter; ZeroMemory(&di2, sizeof(DRIVER_INFO_2)); di2.cVersion = 1024; di2.pName = "HP Laserjet 4Si"; di2.pEnvironment = "Windows 4.0"; di2.pDriverPath = "c:\\windows\\system\\hppcl5ms.drv"; di2.pDataFile = "c:\\windows\\system\\hppcl5ms.drv"; di2.pConfigFile = "c:\\windows\\system\\hppcl5ms.drv"; AddPrinterDriver(NULL, 2, (LPBYTE)&di2); ZeroMemory(&pi2, sizeof(PRINTER_INFO_2)); pi2.pPrinterName = "HP Laserjet 4Si"; pi2.pPortName = "\\\\server\\print_share"; pi2.pDriverName = "HP Laserjet 4Si"; pi2.pPrintProcessor = "WinPrint"; pi2.pDatatype = "EMF"; hPrinter = AddPrinter(NULL, 2, (LPBYTE)&pi2); ClosePrinter(hPrinter); You can add a printer connection under Windows NT by making this call:
AddPrinterConnection ("\\\\server\\print_share"); |
Additional reference words: kbinf 4.00
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |