AddPrinterDriverEx

[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
);
 

Parameters

pName
Pointer to a null-terminated string that specifies the name of the server on which the driver should be installed. If this parameter is NULL, the function installs the driver on the local computer.
Level
Specifies the version of the structure to which pDriverInfo points. This value can be either 2 or 3.
pDriverInfo
Pointer to a structure containing printer driver information. If Level is 2, pDriverInfo is a pointer to a DRIVER_INFO_2 structure. If Level is 3, pDriverInfo is a pointer to a DRIVER_INFO_3 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.

dwFileCopyFlags
Specifies options for copying the driver files. This parameter can be one of the following values.
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.

Return Values

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.

Remarks

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.

QuickInfo

  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.

See Also

Printing and Print Spooler Overview, Printing and Print Spooler Functions, DRIVER_INFO_2, DRIVER_INFO_3, DeletePrinterDriverEx, EnumPrinterDrivers, GetPrinterDriverDirectory