How to Add a Network Printer ConnectionID: Q147202
|
When 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.
This 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.
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);
AddPrinterConnection ("\\\\server\\print_share");
Additional query words: kbinf 4.00 KBINF GDI WINDOWS 95 GRAPHICS PRINTING
Keywords : kbcode GdiPrnDrvrs
Version : 4.00 | 3.51
Platform : NT WINDOWS
Issue type :
Last Reviewed: March 6, 1999