如何通过代码更改后台打印/直接打印设置? [英] How to change the spool/direct print setting via code?

查看:308
本文介绍了如何通过代码更改后台打印/直接打印设置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在打印属性中更改设置,该设置指定:1.假脱机打印文档..."或2.直接打印到打印机".

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

此答案中... J ...表示可以使用

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

MSDN PrintQueue.isDirect (只读属性)这样说:只能设置此属性 通过Windows的通用打印对话框."

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

我认为这专门适用于.net,从绝对意义上讲可能并非正确.那么如何通过代码更改后台打印/打印直接设置?

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?

推荐答案

来自J ...的评论

引用来自: Windows后台处理程序注册表

可以通过Windows注册表设置各种打印机选项.每个 已安装的打印机在以下注册表路径中具有一个子项: HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Control \ Print \ Printers \

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\

在此之下,在属性Attributes的值中有一个属性位图: REG_DWORD 0002(0x0002)直接:将文档直接发送到 打印机.

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.

请注意,此注册表值包含多个属性.有关更多详细信息,请参见 Windows后台处理程序注册表.

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.

这篇关于如何通过代码更改后台打印/直接打印设置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆