GetPrinterData function
The GetPrinterData function retrieves configuration data for the specified printer or print server.
In Windows 2000 and later versions of Windows, calling GetPrinterData is equivalent to calling GetPrinterDataEx with the pKeyName parameter set to "PrinterDriverData".
Syntax
DWORD GetPrinterData(
_In_ HANDLE hPrinter,
_In_ LPTSTR 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.
-
pValueName [in]
-
A 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 [out]
-
A pointer to a variable that receives a value that indicates the type of data retrieved in pData. The function returns the type specified in the SetPrinterData or SetPrinterDataEx call that stored the data. Set this parameter to NULL if you don't need the data type.
-
pData [out]
-
A pointer to a buffer that receives the configuration data.
-
nSize [in]
-
The size, in bytes, of the buffer that pData points to.
-
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.
GetPrinterData retrieves printer configuration data that was set by the SetPrinterDataEx or SetPrinterData function.
GetPrinterData might trigger a Windows call to GetPrinterDataFromPort, which might write to the registry. If it does, side effects can occur, such as triggering an update or upgrade printer event ID 20 in the client, if the printer is shared in a network.
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. |
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 following values configure client-side rendering of a print jobs and can be read if you set the following values in pValueName.
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 |
|
Library |
|
DLL |
|
Unicode and ANSI names |
GetPrinterDataW (Unicode) and GetPrinterDataA (ANSI) |