How to change the spool/direct print setting via c

2019-09-10 11:04发布

问题:

I need to change the setting in the print properties that specifies either: 1. "Spool print documents..." or 2. "Print directly to the printer."

In this answer J... indicates that this can be done using the PrintQueue Class. How?

MSDN PrintQueue.isDirect (ReadOnly Property) says this: "This property can be set only through the Windows common print dialog."

I assume that applies specifically to .net and may not be true in the absolute sense. So how to change the spool/print direct setting via code?

回答1:

From comment of J...

Quoting from: Windows Spooler Registry

Various printer options can be set via the windows registry. Each installed printer has a subkey in the following Registry path: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Print\Printers\

Under this there is a attributes bitmap, in the value Attributes : REG_DWORD 0002 (0x0002) Direct: Document to be sent directly to the printer.

The spooler service might need to be restarted, for the changes to take effect.

Note that this registry value contains multiple attributes. See Windows Spooler Registry for more details.

Warning Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. Modify the registry at your own risk.