GetPrinterDriver

  BOOL GetPrinterDriver(hPrinter, pEnvironment, Level, pDriverInfo, cbBuf, pcbNeeded)    
  HANDLE hPrinter;    
  LPTSTR pEnvironment;    
  DWORD Level;    
  LPBYTE pDriverInfo;    
  DWORD cbBuf;    
  LPDWORD pcbNeeded;    

The GetPrinterDriver function retrieves information about a specified printer driver.

Parameters

hPrinter

Indicates the open Printer handle that this function is to be performed upon. This Handle is obtained with the OpenPrinter function.

pEnvironment

Pointer to a string that specifies the machine and operating system environment. An example is the string “W32X86”.

Level

This value cvan be either 1, or 2.

pDriverInfo

A pointer to a buffer that the function will fill with a DRIVER_INFO_1, or DRIVER_INFO_2 data structure that describes the printer driver.

cbBuf

Specifies the size in bytes of the buffer pointed to by pDriverInfo.

pcbNeeded

This points to a variable that will be updated to contain the actual buffer size required that is pointed to by pDriverInfo. If cbBuf is too small then GetLastError will indicate ERROR_BUFFER_TOO_SMALL, and pcbNeeded will contain the size required. If cbBuf is large enough, then pcbNeeded will contain the number of bytes that were copied.

Return Value

The return value is TRUE if the function was successful, or FALSE if an error occurred. To obtain extended error information, use the GetLastError function.

Comments

One piece of information included in a DRIVERINFO data structure is the fully-qualified pathname of the printer driver. An application can then load the driver by calling LoadLibrary. Win32 does this itself when it needs to know the printer driver to load when executing the CreateDC function.

See Also

AddPrinterDriver, EnumPrinterDrivers