如何在 Windows 中创建虚拟打印机?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1019036/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to create a virtual printer in Windows?
提问by Terminus
I want to create a virtual printer driver for Windows. How and where can I start properly? The WDK has some printing drivers examples that do not seems a good introductory. MSDN also doesn't seems to be very helpful for a novice.
我想为 Windows 创建一个虚拟打印机驱动程序。我如何以及在哪里可以正确开始?WDK 有一些打印驱动程序示例,这些示例似乎不是很好的介绍。MSDN 似乎对新手也不是很有帮助。
There are a lot of virtual printers for Windows out there (mostly they generate PDFs), I wonder if someone could tell my how can I do the same?
有很多适用于 Windows 的虚拟打印机(主要是它们生成 PDF),我想知道是否有人可以告诉我如何做同样的事情?
Any links to the elaborating documentations are appreciated in advance.
任何指向详细文档的链接都提前表示感谢。
Thanks.
谢谢。
采纳答案by ChrisW
When I did it (which about 12 years ago) I started with the postscript driver sample, replaced all the postscript-specific stuff (in my case, to write to a bitmap instead of generating postscript commands).
当我这样做时(大约 12 年前),我从 postscript 驱动程序示例开始,替换了所有 postscript 特定的东西(在我的情况下,写入位图而不是生成 postscript 命令)。
I also wrote a custom print monitor (the driver writes to the spooler, which write to a monitor): my monitor wrote to a file instead of e.g. to the parallel port.
我还编写了一个自定义打印监视器(驱动程序写入后台处理程序,后者写入监视器):我的监视器写入文件而不是例如并行端口。
However, printer driver architecture and/or the set of sample drivers may have changed since then.
但是,打印机驱动程序架构和/或示例驱动程序集可能从那时起就发生了变化。
回答by Douglas Anderson
You can look to the 'minidriver' development in the from Microsoft (Microsoft MDT), that might help depending on your exact needs. If the port you need to deal with (ie: you are going to take the data from an existing printer driver and want to process) you could look to the source code for RedMon. It doesn't support Vista/Win7 but might point you in the right direction.
您可以查看 Microsoft (Microsoft MDT) 中的“微型驱动程序”开发,这可能会有所帮助,具体取决于您的具体需求。如果您需要处理端口(即:您将从现有打印机驱动程序中获取数据并想要处理),您可以查看 RedMon 的源代码。它不支持 Vista/Win7,但可能会为您指明正确的方向。
回答by pedrofernandes
This book maybe help you Developing Drivers with the Windows? Driver Foundation
这本书也许可以帮助您使用 Windows 开发驱动程序?司机基础
A list of my links
我的链接列表
- http://www.codeproject.com/KB/system/driverdev.aspx
- http://www.microsoft.com/whdc/ddk/winddk.mspx
- http://jungo.com/wdusb.html
- https://web.archive.org/web/20130717135254/https://msdn.microsoft.com/en-us/library/ff554651.aspx
- http://channel9.msdn.com/posts/Rory/Driver-Development-and-Much-More-With-Mike-Calligaro/
- http://www.codeproject.com/KB/system/driverdev.aspx
- http://www.microsoft.com/whdc/ddk/winddk.mspx
- http://jungo.com/wdusb.html
- https://web.archive.org/web/20130717135254/https://msdn.microsoft.com/en-us/library/ff554651.aspx
- http://channel9.msdn.com/posts/Rory/Driver-Development-and-Much-More-With-Mike-Calligaro/
回答by Jon Bright
Someone else already mentioned PDFCreator. Here's a more specific link to their code that's creating the printer, port and monitor. Despite being in VB, I can follow it as someone more used to C++, so I guess you can too. modPrinter.basdoes the leg work. modMain.bas, from about line 28 onwards, calls into modPrinter.bas.
其他人已经提到了 PDFCreator。这是他们创建打印机、端口和监视器的代码的更具体的链接。尽管在 VB 中,我可以像更习惯 C++ 的人一样遵循它,所以我想你也可以。 modPrinter.bas做腿部工作。 modMain.bas从大约第 28 行开始,调用 modPrinter.bas。
回答by JCCyC
One of the drivers you mention is open-source (GPL), maybe you could explore its source or adapt it: http://www.pdfforge.org/products/pdfcreator/download
您提到的驱动程序之一是开源(GPL),也许您可以探索其源代码或对其进行调整:http: //www.pdfforge.org/products/pdfcreator/download
回答by JCCyC
Create a Print Port Monitor, associate that port with a printer, and you'll get the data the printer driver sends to the port.
创建打印端口监视器,将该端口与打印机相关联,您将获得打印机驱动程序发送到该端口的数据。
working example of how is it done in Cpp and java can be found here: http://www.mms-computing.co.uk/uk/co/mmscomputing/device/printmonitor/index.php
可以在此处找到如何在 Cpp 和 java 中完成的工作示例:http: //www.mms-computing.co.uk/uk/co/mmscomputing/device/printmonitor/index.php