GetPrinterDataEx function

The GetPrinterDataEx function retrieves configuration data for the specified printer or print server. GetPrinterDataEx can retrieve values that the SetPrinterData function stored. In addition, GetPrinterDataEx can retrieve values that the SetPrinterDataEx function stored under a specified key.

Syntax

DWORD GetPrinterDataEx(
  _In_  HANDLE  hPrinter,
  _In_  LPCTSTR pKeyName,
  _In_  LPCTSTR pValueName,
  _Out_ LPDWORD pType,
  _Out_ LPBYTE  pData,
  _In_  DWORD   nSize,
  _Out_ LPDWORD pcbNeeded
);

Parameters

hPrinter [in]

A handle to the printer or print server for which the function retrieves configuration data. Use the OpenPrinter, OpenPrinter2, or AddPrinter function to retrieve a printer handle.

pKeyName [in]

A pointer to a null-terminated string that specifies the key containing the value to be retrieved. Use the backslash ( \ ) character as a delimiter to specify a path that has one or more subkeys.

If hPrinter is a handle to a printer and pKeyName is NULL or an empty string, GetPrinterDataEx returns ERROR_INVALID_PARAMETER.

If hPrinter is a handle to a print server, pKeyName is ignored.

pValueName [in]

A pointer to a null-terminated string that identifies the data to retrieve.

For printers, this string specifies the name of a value under the pKeyName key.

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

pType [out]

A pointer to a variable that receives the type of data stored in the value. The function returns the type specified in the SetPrinterDataEx call when the data was stored. This parameter can be NULL if you don't need the information. GetPrinterDataEx passes pType on as the lpdwType parameter of a RegQueryValueEx function call.

pData [out]

A pointer to a buffer that receives the configuration data.

nSize [in]

The size, in bytes, of the buffer pointed to by pData.

pcbNeeded [out]

A 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 value

If the function succeeds, the return value is ERROR_SUCCESS.

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

Remarks

Note

This is a blocking or synchronous function and might not return immediately. How quickly this function returns depends on run-time factors such as network status, print server configuration, and printer driver implementation factors that are difficult to predict when writing an application. Calling this function from a thread that manages interaction with the user interface could make the application appear to be unresponsive.

GetPrinterDataEx retrieves printer-configuration data that was set by the SetPrinterDataEx and SetPrinterData functions.

Calling GetPrinterDataEx with the pKeyName parameter set to "PrinterDriverData" is equivalent to calling the GetPrinterData function.

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

Value Comments
SPLREG_ALLOW_USER_MANAGEFORMS Windows XP with Service Pack 2 (SP2) and later
Windows Server 2003 with Service Pack 1 (SP1) and later
SPLREG_ARCHITECTURE
SPLREG_BEEP_ENABLED
SPLREG_DEFAULT_SPOOL_DIRECTORY
SPLREG_DNS_MACHINE_NAME
SPLREG_DS_PRESENT On successful return, pData contains 0x0001 if the machine is on a DS domain, 0 otherwise.
SPLREG_DS_PRESENT_FOR_USER On successful return, pData contains 0x0001 if the user is logged onto a DS domain, 0 otherwise.
SPLREG_EVENT_LOG
SPLREG_MAJOR_VERSION
SPLREG_MINOR_VERSION
SPLREG_NET_POPUP Not supported in Windows Server 2003 and later
SPLREG_NET_POPUP_TO_COMPUTER On successful return, pData contains 1 if job notifications should be sent to the client computer, or 0 if job notifications are to be sent to the user.
Not supported in Windows Server 2003 and later
SPLREG_OS_VERSION Windows XP and later
SPLREG_OS_VERSIONEX
SPLREG_PORT_THREAD_PRIORITY_DEFAULT
SPLREG_PORT_THREAD_PRIORITY
SPLREG_PRINT_DRIVER_ISOLATION_GROUPS Windows 7 and later
SPLREG_PRINT_DRIVER_ISOLATION_TIME_BEFORE_RECYCLE Windows 7 and later
SPLREG_PRINT_DRIVER_ISOLATION_MAX_OBJECTS_BEFORE_RECYCLE Windows 7 and later
SPLREG_PRINT_DRIVER_ISOLATION_IDLE_TIMEOUT Windows 7 and later
SPLREG_PRINT_DRIVER_ISOLATION_EXECUTION_POLICY Windows 7 and later
SPLREG_PRINT_DRIVER_ISOLATION_OVERRIDE_POLICY Windows 7 and later
SPLREG_REMOTE_FAX On successful return, pData contains 0x0001 if the FAX service supports remote clients, 0 otherwise.
SPLREG_RETRY_POPUP On successful return, pData contains 1 if server is set to retry pop-up windows for all jobs, or 0 if server does not retry pop-up windows for all jobs.
Not supported in Windows Server 2003 and later
SPLREG_SCHEDULER_THREAD_PRIORITY
SPLREG_SCHEDULER_THREAD_PRIORITY_DEFAULT
SPLREG_WEBSHAREMGMT Windows Server 2003 and later

The following values of pValueName indicate the pool printing behavior when an error occurs.

Value Comments
SPLREG_RESTART_JOB_ON_POOL_ERROR The value of pData indicates the time, in seconds, when a job is restarted on another port after an error occurs. This setting is used with SPLREG_RESTART_JOB_ON_POOL_ENABLED.
SPLREG_RESTART_JOB_ON_POOL_ENABLED A nonzero value in pData indicates that SPLREG_RESTART_JOB_ON_POOL_ERROR is enabled.

The time specified in SPLREG_RESTART_JOB_ON_POOL_ERROR is a minimum time. The actual time can be longer, depending on the following port monitor settings, which are registry values under this registry key:

HKLM\SYSTEM\CurrentControlSet\Control\Print\Monitors\<MonitorName>\Ports

Call the RegQueryValueEx function to query these values.

Port monitor setting Data type Meaning
StatusUpdateEnabled REG_DWORD If a nonzero value, enables the port monitor to update the spooler with the port status.
StatusUpdateInterval REG_DWORD Specifies the interval, in minutes, when the port monitor updates the spooler with the port status.

If pKeyName is one of the predefined Directory Service (DS) keys (see SetPrinter) and pValueName contains a comma (','), then the portion of pValueName before the comma is the value name and the portion of pValueName to the right of the comma is the DS Property OID. A subkey called OID is created and a new value that consists of the value name and OID is entered under the OID key. SetPrinterDataEx also adds the value name and data under the DS key.

In Windows 7 and later versions of Windows, print jobs that are sent to a print server are rendered on the client by default. The configuration of client-side rendering for a printer can be read by setting pKeyName to "PrinterDriverData" and pValueName to the setting value in the following table.

Setting Data type Description
EMFDespoolingSetting REG_DWORD A value of 0, or if this value is not present in the registry, enables the default client-side rendering of print jobs.
A value of 1 disables client-side rendering of print jobs.
ForceClientSideRendering REG_DWORD A value of 0, or if this value is not present in the registry, will cause the print jobs to be rendered on the client. If a print job cannot be rendered on the client, it will be rendered on the server. If a print job cannot be rendered on the server, it will fail.
A value of 1 will render print jobs on the client. If a print job cannot be rendered on the client, it will fail.

Requirements

Requirement Value
Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Winspool.h (include Windows.h)
Library
Winspool.lib
DLL
Winspool.drv
Unicode and ANSI names
GetPrinterDataExW (Unicode) and GetPrinterDataExA (ANSI)

See also

Printing

Print Spooler API Functions

OpenPrinter

SetPrinterDataEx