编写 Windows 打印机驱动程序 [英] Writing a Windows Printer Driver

查看:174
本文介绍了编写 Windows 打印机驱动程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用 C++ 或 C# 编写一个应用程序,该应用程序在安装时将充当打印机驱动程序.它将在打印"对话框的下拉列表中可用,但它不会打印,而是会调用我的代码.

I want to write a application in C++ or C# that will behave as a printer driver when installed. It will be available in the drop down list in Print dialog but instead of printing it will call into my code.

我认为 Windows 可能会提供一些接口来编写打印机驱动程序.

I think there may be some interfaces that Windows provide to write printer drivers.

推荐答案

Windows 提供了大量的接口.你知道你想写什么样的打印机驱动程序吗?目前,Windows 支持三种类型的打印机驱动程序——PostScript、Unidrv 和 XPSDrv(后者仅在 EP 1.0 及更高版本的 XP/2003 Server 上运行).大多数情况下,编写驱动程序插件就足够了.阅读 INF 架构以了解安装这些东西,特别是关于微型驱动程序的部分.

Windows provides loads of interfaces. Do you know what sort of a printer driver you want to write? At present, Windows supports three flavors of printer drivers -- PostScript, Unidrv and XPSDrv (the latter on XP/2003 Server with EP 1.0 and upwards only). Most of the time, it suffices to write a driver plug-in instead. Read up on INF architecture to know these things get installed, specially the section on minidrivers.

按照建议,您将需要 WDK 才能构建驱动程序或其插件.请注意,驱动程序不使用 Visual Studio IDE 或编译器.WDK 带有自己的编译器.你总是可以将后者与 VS 联系起来,但那是另一回事了.

As suggested, you will need the WDK to be able to build a driver or a plug-in thereof. Note that drivers do not use the Visual Studio IDE or compilers. The WDK comes with a compiler of its own. You can always hook up the latter with VS, but that's a different story.

WDK 具有针对不同操作系统的设置.您必须知道要解决哪个操作系统(或一组操作系统)并选择适当的设置.

The WDK has setups to target different OS-es. You will have to know which OS (or set of OS-es) you want to address and choose the appropriate setup.

我想编写一个将显示在打印机列表中的简单驱动程序.

I want to write a simple driver that will displays in the list of printers.

我看不出这会有什么帮助.如果您正在编写驱动程序,为什么要列出系统中存在的所有其他驱动程序?

I don't see how that will be helpful. If you are writing a driver, why would you want a list of all other drivers present on the system?

打印到此驱动程序将调用我的代码,以便我可以执行诸如创建文档的 PDF、调用 Web 服务等操作.

Printing to this driver will call into my code so that I can do stuff like create a PDF of the document, calling the Web Service etc.

有趣!您可以在 UI 插件中实现所有这些功能.UI 插件是在您选择 Advanced 驱动程序属性时加载的 dll.

Interesting! You can achieve all those things in a UI plug-in. An UI plug-in is a dll that is loaded when you select the Advanced driver properties.

要开始使用 UI 插件,请查看 WDK 中的示例 oemui 源代码.

To get started with UI plug-ins take a look at the sample oemui source code in the WDK.

这篇关于编写 Windows 打印机驱动程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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