首页 > 代码库 > winspool.drv
winspool.drv
public partial class Form1 : Form
{ [System.Runtime.InteropServices.DllImportAttribute("winspool.drv", SetLastError = true)] public extern static int DocumentProperties( IntPtr hWnd, // handle to parent window IntPtr hPrinter, // handle to printer object string pDeviceName, // device name ref IntPtr pDevModeOutput, // modified device mode ref IntPtr pDevModeInput, // original device mode int fMode); // mode options [System.Runtime.InteropServices.DllImportAttribute("winspool.drv")] public static extern int PrinterProperties( IntPtr hwnd, // handle to parent window IntPtr hPrinter); // handle to printer object [System.Runtime.InteropServices.DllImportAttribute("winspool.drv", SetLastError = true)] public extern static int OpenPrinter( string pPrinterName, // printer name ref IntPtr hPrinter, // handle to printer object ref IntPtr pDefault); // handle to default printer object. [System.Runtime.InteropServices.DllImportAttribute("winspool.drv", SetLastError = true)] public static extern int ClosePrinter( IntPtr phPrinter); // handle to printer object public Form1() { InitializeComponent(); }
/// <summary>
/// 调用API打开打印机属性窗口
/// </summary>
private void button1_Click(object sender, EventArgs e) { string printerName = "ZEBRA R110Xi4 300DPI"; if (printerName != null && printerName.Length > 0) { IntPtr pPrinter = IntPtr.Zero; IntPtr pDevModeOutput = IntPtr.Zero; IntPtr pDevModeInput = IntPtr.Zero; IntPtr nullPointer = IntPtr.Zero; OpenPrinter(printerName, ref pPrinter, ref nullPointer); int iNeeded = PrinterProperties(this.Handle, pPrinter); ClosePrinter(pPrinter); } }
///<summary>
///调用API打开Document property窗口
///</summary> private void button2_Click(object sender, EventArgs e) { string printerName = "ZEBRA R110Xi4 300DPI"; if (printerName != null && printerName.Length > 0) { IntPtr pPrinter = IntPtr.Zero; IntPtr pDevModeOutput = IntPtr.Zero; IntPtr pDevModeInput = IntPtr.Zero; IntPtr nullPointer = IntPtr.Zero; OpenPrinter(printerName, ref pPrinter, ref nullPointer); int iNeeded = DocumentProperties(this.Handle, pPrinter, printerName, ref pDevModeOutput, ref pDevModeInput, 0); pDevModeOutput = System.Runtime.InteropServices.Marshal.AllocHGlobal(iNeeded); DocumentProperties(this.Handle, pPrinter, printerName, ref pDevModeOutput, ref pDevModeInput, 14); ClosePrinter(pPrinter); } } }
winspool.drv
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。