调用api弹出打印机属性对话框
Author:vitoriatang
From:Internet
.NET Framework封装了很多关于打印的对话框,比如说PrintDialog, PageSetupDialog.
但是有的时候我们还需要关心打印机属性对话框,那么就可以调用API来解决这个问题。有几个API函数与之相关
PrinterProperties
DocumentProperties
OpenPrinter
ClosePrinter
逐一介绍
printerproperties
显示打印机属性对话框。
documentproperties
显示打印机配置对话框。
openprinter
打开打印机
closeprinter
关闭打印机
在调用printerproperties或者documentproperties的时候,都需要先调用openprinter,并在结束后调用closeprinter。
至于打印机属性和打印机配置有什么不同,就自己领会了。更为详尽的信息可以查阅msdn
sample codes:
1. 声明API函数
[System.Runtime.InteropServices.DllImportAttribute("winspool.drv", SetLastError = true)]
public extern static int DocumentProperties(
IntPtr hWnd, // handle to parent window
IntPtr hPrinter, /