[This is preliminary documentation and subject to change.]
The SetPrinterDataEx function sets the configuration data for a printer. The function stores the configuration data under the printer's key in the registry.
DWORD SetPrinterDataEx(
HANDLE hPrinter, // handle to printer or print server
LPCTSTR pKeyName, // name of registry key
LPCTSTR pValueName, // name of registry value
DWORD Type, // type of data stored in registry value
LPBYTE pData, // pointer to configuration data
DWORD cbData // size, in bytes, of configuration data
);
To store configuration data that can be published in the directory service (DS), specify one of the following predefined registry keys.
Value | Meaning |
---|---|
SPLDS_DRIVER_KEY | Printer drivers use this key to store driver properties. |
SPLDS_SPOOLER_KEY | Used only by the print spooler to store internal spooler properties. |
SPLDS_USER_KEY | Applications use this key to store printer properties such as printer asset numbers. |
Values stored under the the SPLDS_USER_KEY key are published in the directory service only if there is a corresponding property in the schema. A domain administrator must create the property if it doesn't already exist.
You can specify other keys to store non-DS configuration data. Use the backslash ( \ ) character as a delimiter to specify a path that has one or more subkeys.
If hPrinter identifies a printer and pKeyName is NULL or an empty string, SetPrinterDataEx returns ERROR_INVALID_PARAMETER.
If hPrinter identifies a print server, pKeyName must be NULL.
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.
If pKeyName specifies one of the predefined directory service keys, Type must be REG_SZ, REG_MULTI_SZ, REG_DWORD, or REG_BINARY. If REG_BINARY is used, cbData must be equal to 1, and the directory service treats the data as a Boolean value.
For non-DS keys, the Type parameter can be one of the following values.
Value | Meaning |
---|---|
REG_BINARY | Binary data in any form. |
REG_DWORD | A 32-bit number. |
REG_DWORD_LITTLE_ENDIAN | A 32-bit number in little-endian format. This is equivalent to REG_DWORD. In little-endian format, a multibyte value is stored in memory from the lowest byte (the "little end") to the highest byte. For example, the value 0x12345678 is stored as (0x78 0x56 0x34 0x12) in little-endian format. Windows and Windows NT are designed to run on little-endian computer architectures. A user may connect to computers that have big-endian architectures, such as some UNIX systems. |
REG_DWORD_BIG_ENDIAN | A 32-bit number in big-endian format. In big-endian format, a multibyte value is stored in memory from the highest byte (the "big end") to the lowest byte. For example, the value 0x12345678 is stored as (0x12 0x34 0x56 0x78) in big-endian format. |
REG_EXPAND_SZ | A null-terminated string that contains unexpanded references to environment variables (for example, "%PATH%"). It will be a Unicode or ANSI string, depending on whether you use the Unicode or ANSI functions. |
REG_LINK | A Unicode symbolic link. |
REG_MULTI_SZ | An array of null-terminated strings, terminated by two null characters. |
REG_NONE | No defined value type. |
REG_RESOURCE_LIST | A device-driver resource list. |
REG_SZ | A null-terminated string. It will be a Unicode or ANSI string, depending on whether you use the Unicode or ANSI functions. |
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value is an error value.
To retrieve existing configuration data for a printer, call the GetPrinterDataEx 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 |
Calling SetPrinterDataEx with the pKeyName parameter set to "PrinterDriverData" is equivalent to calling the SetPrinterData function.
Windows NT: Requires version 5.0 or later.
Windows: Unsupported.
Windows CE: Unsupported.
Header: Declared in winspool.h.
Import Library: Use winspool.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT.
Printing and Print Spooler Overview, Printing and Print Spooler Functions, GetPrinterDataEx, OpenPrinter