GetPrinterDriver

The GetPrinterDriver function retrieves driver data for the specified printer.

BOOL GetPrinterDriver(
  HANDLE hPrinter,     // printer object
  LPTSTR pEnvironment, // address of environment
  DWORD Level,         // structure level
  LPBYTE pDriverInfo,  // address of structure array
  DWORD cbBuf,         // size, in bytes, of array
  LPDWORD pcbNeeded    // address of variable with number of bytes 
                       // retrieved (or required)
);
 

Parameters

hPrinter
Handle to the printer for which the driver data should be retrieved.
pEnvironment
Pointer to a null-terminated string that specifies the environment (for example, "Windows NT x86", "Windows NT R4000", "Windows NT Alpha_AXP", or "Windows 4.0"). If this parameter is NULL, the current environment of the calling application and client machine (not of the destination application and print server) is used.
Level
Specifies the version of the structure to which lpbForm points. This value must be either 1, 2., or 3.
pDriverInfo
Pointer to either a DRIVER_INFO_1, DRIVER_INFO_2, or DRIVER_INFO_3 structure. If Level is 1, this array receives a DRIVER_INFO_1 structure; if Level is 2, this array receives a DRIVER_INFO_2 structure, if Level is 3, this array receives a DRIVER_INFO_3 structure.
cbBuf
Specifies the size, in bytes, of the array at which pDriverInfo points.
pcbNeeded
Pointer to a value that specifies the number of bytes copied if the function succeeds or the number of bytes required if cbBuf is too small.

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

The printer handle identified by the hPrinter parameter should be retrieved by calling the OpenPrinter function.

The DRIVER_INFO_2 and DRIVER_INFO_3 structures contain a full path and filename specifying the location of the printer driver. An application can use the path and filename to load a printer driver by calling the LoadLibrary function and supplying the path and filename as the single argument.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Requires Windows 95 or later.
  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, AddPrinterDriver, DRIVER_INFO_1, DRIVER_INFO_2, EnumPrinterDrivers, LoadLibrary, OpenPrinter