The GetPrinterDriver2 function retrieves driver data for the specified printer. If the driver is not installed on the local computer, GetPrinterDriver2 installs it and displays any user interface to the specified window.
BOOL GetPrinterDriver2( _In_opt_ HWND hWnd, _In_ HANDLE hPrinter, _In_opt_ LPTSTR pEnvironment, _In_ DWORD Level, _Out_ LPBYTE pDriverInfo, _In_ DWORD cbBuf, _Out_ LPDWORD pcbNeeded );
- hWnd [in, optional]
A handle of the window that will be used as the parent window of any user interface, such as a dialog box, that the driver displays during installation. If the value of this parameter is NULL, the driver's user interface will still be displayed to the user during installation, but it will not have a parent window.
- hPrinter [in]
- pEnvironment [in, optional]
A pointer to a null-terminated string that specifies the environment (for example, Windows x86, Windows IA64, or Windows x64). 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 [in]
The printer driver structure returned in the pDriverInfo buffer. This parameter can be one of the following values.
- pDriverInfo [out]
A pointer to a buffer that receives a structure containing information about the driver, as specified by Level. The buffer must be large enough to store the strings pointed to by the structure members.
To determine the required buffer size, call GetPrinterDriver2 with cbBuf set to zero. GetPrinterDriver2 fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the pcbNeeded parameter returns the size, in bytes, of the buffer required to hold the array of structures and their data.
- cbBuf [in]
The size, in bytes, of the array at which pDriverInfo points.
- pcbNeeded [out]
A pointer to a value that receives the number of bytes copied if the function succeeds or the number of bytes required if cbBuf is too small.
If the function succeeds, the return value is a nonzero value.
If the function fails, the return value is zero. To get the return status, call GetLastError.
The DRIVER_INFO_2, DRIVER_INFO_3, DRIVER_INFO_4, DRIVER_INFO_5, DRIVER_INFO_6, and DRIVER_INFO_8 structures contain the file name or the full path and file name of the printer driver in the pDriverPath member. 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.
The ANSI version of this function, GetPrinterDriver2A is not supported and returns ERROR_NOT_SUPPORTED.
Minimum supported client
|Windows Vista [desktop apps only]|
Minimum supported server
|Windows Server 2008 [desktop apps only]|
Unicode and ANSI names
- Print Spooler API Functions