Export (0) Print
Expand All

GetPrinterDriver2 function

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.

Syntax


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
);

Parameters

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]

A handle to the printer for which the driver data should be retrieved. Use the OpenPrinter or AddPrinter function to retrieve a printer handle.

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.

ValueMeaning
1

DRIVER_INFO_1

2

DRIVER_INFO_2

3

DRIVER_INFO_3

4

DRIVER_INFO_4

5

DRIVER_INFO_5

6

DRIVER_INFO_6

8

DRIVER_INFO_8

 

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.

Return value

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.

Remarks

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.

Requirements

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Winspool.h (include Windows.h)

Library

Winspool.lib

DLL

Winspool.drv

Unicode and ANSI names

GetPrinterDriver2W (Unicode)

See also

Printing
Print Spooler API Functions
AddPrinterDriver
DRIVER_INFO_1
DRIVER_INFO_2
DRIVER_INFO_3
DRIVER_INFO_4
DRIVER_INFO_5
DRIVER_INFO_6
EnumPrinterDrivers
GetPrinterDriver
OpenPrinter

 

 

Community Additions

ADD
Show:
© 2015 Microsoft