SetPrinterData function
The SetPrinterData function sets the configuration data for a printer or print server.
To specify the registry key under which to store the data, call the SetPrinterDataEx function. Calling SetPrinterData is equivalent to calling the SetPrinterDataEx function with the pKeyName parameter set to "PrinterDriverData".
Syntax
DWORD SetPrinterData(
_In_ HANDLE hPrinter,
_In_ LPTSTR pValueName,
_In_ DWORD Type,
_In_ LPBYTE pData,
_In_ DWORD cbData
);
Parameters
-
hPrinter [in]
-
A handle to the printer or print server for which the function sets 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 set.
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.
-
Type [in]
-
A code that indicates the type of data that the pData parameter points to. For a list of the possible type codes, see Registry Value Types.
-
pData [in]
-
A pointer to an array of bytes that contains the printer configuration data.
-
cbData [in]
-
The size, in bytes, of the array.
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.
To retrieve existing configuration data for a printer, call the GetPrinterDataEx or 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_BEEP_ENABLED | |
SPLREG_DEFAULT_SPOOL_DIRECTORY | |
SPLREG_EVENT_LOG | |
SPLREG_NET_POPUP | Not supported in Windows Server 2003 and later |
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_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 determine 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 RegSetValueEx function to set 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. Client-side rendering of a print jobs can be configured for each printer by setting 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, causes 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 |
SetPrinterDataW (Unicode) and SetPrinterDataA (ANSI) |