GetPrinterData

The GetPrinterData function retrieves configuration data for the specified printer or print server.

Windows NT 5.0 or later: Calling GetPrinterData is equivalent to calling the GetPrinterDataEx function with the pKeyName parameter set to "PrinterDriverData".

DWORD GetPrinterData(
  HANDLE hPrinter,    // handle to a printer or print server
  LPTSTR pValueName,  // string that identifies the data to retrieve
  LPDWORD pType,      // variable that receives the type of data
  LPBYTE pData,       // buffer that receives the configuration data
  DWORD nSize,        // size, in bytes, of buffer
  LPDWORD pcbNeeded   // receives the required buffer size, in bytes 
);
 

Parameters

hPrinter
Handle to the printer or print server for which the function retrieves configuration data. Use the OpenPrinter function to retrieve this handle.
pValueName
Pointer to a null-terminated string that identifies the data to retrieve.

For printers, this string is the name of a registry value under the printer's "PrinterDriverData" key in the registry.

For print servers, this string is one of the predefined strings listed in the following Remarks section.

pType
Pointer to a variable that receives the type of data retrieved. The function returns the type specified in the SetPrinterData or SetPrinterDataEx call when the data was stored. This parameter can be NULL if you don't need the information.
pData
Pointer to a buffer that receives the configuration data.
nSize
Specifies the size, in bytes, of the buffer pointed to by pData.
pcbNeeded
Pointer to a variable that receives the size, in bytes, of the configuration data. If the buffer size specified by nSize is too small, the function returns ERROR_MORE_DATA, and pcbNeeded indicates the required buffer size.

Return Values

If the function succeeds, the return value is ERROR_SUCCESS.

If the function fails, the return value is an error value.

Remarks

GetPrinterData retrieves printer-configuration data set by the SetPrinterDataEx or SetPrinterData function.

If hPrinter is a handle to a print server, pValueName can specify one of the following predefined values.

SPLREG_DEFAULT_SPOOL_DIRECTORY
SPLREG_PORT_THREAD_PRIORITY_DEFAULT
SPLREG_PORT_THREAD_PRIORITY
SPLREG_SCHEDULER_THREAD_PRIORITY_DEFAULT
SPLREG_SCHEDULER_THREAD_PRIORITY
SPLREG_BEEP_ENABLED
SPLREG_NET_POPUP
SPLREG_EVENT_LOG
SPLREG_MAJOR_VERSION
SPLREG_MINOR_VERSION
SPLREG_ARCHITECTURE
SPLREG_OS_VERSION

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, GetPrinterDataEx, OpenPrinter, SetPrinter, SetPrinterData, SetPrinterDataEx