GetPrinterDriver

BOOL GetPrinterDriver(
HANDLE  hPrinter,   /* printer object                        */
LPTSTR  lpszEnv,    /* address of environment                */
DWORD   dwLevel,    /* structure level                       */
LPBYTE  lpbDrvInfo, /* address of structure array            */
DWORD   cbBuf,      /* size, in bytes, of array              */
LPDWORD lpdwNeeded  /* addr. of variable with count of bytes */
                    /* retrieved (or required)               */
);
 

Retrieves driver data for the specified printer.

hPrinter Identifies the printer for which to retrieve driver data.
lpszEnv Points to a null-terminated string that specifies the environment. For example, "Windows 96 x86" specifies Windows 96 running on an Intel(r) 80386 or 80486 processor. If this string is NULL, the current environment of the caller/client (not of the destination/server) is used.
dwLevel Specifies the version of the structure to which lpbDrvInfo points. This value must be either 1 or 2.
lpbDrvInfo Points to either a DRIVER_INFO_1 or a DRIVER_INFO_2 structure. If dwLevel is 1, this array receives a DRIVER_INFO_1 structure; if dwLevel is 2, this array receives a DRIVER_INFO_2 structure.
cbBuf Specifies the size, in bytes, of the array at which lpbDrvInfo points.
lpdwNeeded Points 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.

The printer handle hPrinter is obtained by calling the OpenPrinter function.

The DRIVER_INFO_2 structure contains a full path and file name that specifies the location of the printer driver. An application can use the path and file name to load a printer driver by calling the LoadLibrary function and supplying the path and file name as the single argument.