如何显示可用的打印机和打印文件 [英] How to show available printers and print file
本文介绍了如何显示可用的打印机和打印文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将二进制文件发送到C ++程序中的打印机.除了"system lpr"方法外,还有其他方法吗?目前,我以共享打印机(\\ computer-name \ share-name)的身份打开打印机,并且可以正常工作,但是在添加或更改打印机时比较麻烦.寻找一种显示我可用打印机的方法,让用户选择一个打印机,然后将文件发送到选定的打印机.
I need to send a binary file to a printer within a C++ program. Is there a way other than the ''system lpr'' method? Currently I open a printer as a shared printer (\\computer-name\share-name) and this works ok, but is somewhat cumbersome when printers are added or changed. Looking for a way I can display the available printers, have the user select one, and then send the files to the selected printer.
推荐答案
我找到了 ^ ]表示在Win-95/NT时代有一种方法,但是我不确定它现在仍然可以使用;也许仍然值得研究.
I found this link[^] which suggests that there was a method in the days of Win-95/NT, but I cannot be sure that it still works now; perhaps still worth investigating.
使用PrintDlgEx
API显示打印"对话框.
用户可以在此处选择所需的打印机,还可以设置其各种属性.
用户选择要打印的打印机后,PrintDlgEx
的PRINTDLGEX
结构参数将在其hDC
成员中包含所选打印机的设备上下文句柄. 然后,打印到选定的打印机仅是绘制到该打印机设备上下文的问题.
Use thePrintDlgEx
API to show the Print dialog.
Here the user can select the printer of choice and also set its various properties.
After the user selects a printer to print, thePRINTDLGEX
structure parameter toPrintDlgEx
will contain a device context handle to the selected printer in itshDC
member.
Printing to the selected printer is then just a matter of drawing to that printer device context.
这篇关于如何显示可用的打印机和打印文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文