[This is preliminary documentation and subject to change.]
The AddPrinterDriverEx function installs a local or remote printer driver and links the configuration, data, and driver files. In contrast to the AddPrinterDriver function, AddPrinterDriverEx provides more flexibility in installing or upgrading printer drivers. The new options permit strict upgrade, strict downgrade, copying of newer files only and copying of all files (regardless of the file time stamps).
BOOL AddPrinterDriverEx(
LPTSTR pName, // pointer to server name
DWORD Level, // printer info. structure level
LPBYTE pDriverInfo, // pointer to printer info. structure
DWORD dwFileCopyFlags // pointer to printer info. structure
);
If the pEnvironment member of the structure pointed to by pDriverInfo is NULL, the function uses the current environment of the caller/client, not the environment of the destination/server.
Value | Meaning |
---|---|
APD_COPY_ALL_FILES | Add the printer driver and copy all the files in the printer-driver directory. The file time stamps are ignored with this option. |
APD_COPY_NEW_FILES | Add the printer driver and copy the files in the printer-driver directory that are newer than any corresponding files that are currently in use. This flag emulates the behavior of AddPrinterDriver. |
APD_STRICT_DOWNGRADE | Add the printer driver only if all the files in the printer-driver directory are older than any corresponding files that are currently in use. |
APD_STRICT_UPGRADE | Add the printer driver only if all the files in the printer-driver directory are newer than any corresponding files that are currently in use. |
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Before calling the AddPrinterDriverEx function, all files required by the driver must be copied to the system's printer-driver directory. To retrieve the name of this directory, call the GetPrinterDriverDirectory function.
To determine which printer drivers are currently installed, call the EnumPrinterDrivers function.
If the printer driver has been successfully added, the function calls the DrvDriverEvent (DRIVER_EVENT_INITIALIZE, Level, DRIVER_INFO_*, lparam) function to allow the driver to perform any initializations required during the installation of a printer driver. For more information about DrvDriverEvent, see the Microsoft Windows NT Device Driver Kit documentation.
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winspool.h.
Import Library: Use winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Printing and Print Spooler Overview, Printing and Print Spooler Functions, DRIVER_INFO_2, DRIVER_INFO_3, DeletePrinterDriverEx, EnumPrinterDrivers, GetPrinterDriverDirectory