DeletePrinterDriverEx

[This is preliminary documentation and subject to change.]

The DeletePrinterDriverEx is an extended version of the DeletePrinterDriver function.

In addition to removing the specified printer-driver name from the list of names of supported drivers for a server, DeletePrinterDriverEx can also delete the files associated with the driver.

The older DeletePrinterDriver deletes a driver only if no version of the driver is in use for the given environment. DeletePrinterDriverEx can delete specific versions of the driver.

BOOL DeletePrinterDriverEx(
  LPTSTR pName,         // pointer to server name
  LPTSTR pEnvironment,  // pointer to environment
  LPTSTR pDriverName,   // pointer to driver name
  DWORD dwDeleteFlag,   // options for deleting files and versions
  DWORD dwVersionFlag   // version number to delete
);
 

Parameters

pName
Pointer to a null-terminated string that specifies the name of the server from which the driver is to be deleted. If this parameter is NULL, the function deletes the printer-driver from the local computer.
pEnvironment
Pointer to a null-terminated string that specifies the environment from which the driver is to be deleted (for example, "Windows NT x86", "Windows NT R4000", "Windows NT Alpha_AXP", or "Windows 4.0"). If this parameter is NULL, the driver name is deleted from the current environment of the calling application and client computer (not of the destination application and print server).
pDriverName
Pointer to a null-terminated string specifying the name of the driver to delete.
dwDeleteFlag
A set of bit flags that specify options for deleting files and versions of the driver. This parameter can be a combination of the following values.
Value Meaning
DPD_DELETE_SPECIFIC_VERSION Deletes the version specified in dwVersionFlag. This does not ensure that the driver will be removed from the list of supported drivers for the server.
DPD_DELETE_UNUSED_FILES Removes any unused driver files.
DPD_DELETE_ALL_FILES Deletes the driver only if all its associated files can be removed. The delete operation fails if any of the driver's files are being used by some other installed driver.

If DPD_DELETE_SPECIFIC_VERSION is not specified, the function deletes all versions of the driver if none of them is in use. If neither DPD_DELETE_UNUSED_FILES nor DPD_DELETE_ALL_FILES is specified, the function does not delete driver files.

dwVersionFlag
Specifies the version of the driver to be deleted. This parameter can be 0, 1, 2 or 3. This parameter is used only if dwDeleteFlag includes the DPD_DELETE_SPECIFIC_VERSION flag.

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 the function deletes the driver files, it calls the driver's DrvDriverEvent function, allowing the driver to remove any private files that are not used. For more information about DrvDriverEvent, see the Microsoft Windows NT Device Driver Kit documentation.

If the driver files are currently loaded, the function moves them to a temp directory and marks them for deletion on reboot.

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, AddPrinterDriverEx