zoukankan      html  css  js  c++  java
  • 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); } } }
  • 相关阅读:
    机试指南
    Python 切片与深拷贝
    list去重,求差集,保持顺序不变
    python--coding
    python --cookbook
    H5py文件
    面向对象
    企业微信和微信公众号获取wx.config的安卓和ios的区别----踩坑
    vue+vant实现上拉加载下拉刷新(访问后台逻辑)
    vue实现前端跨域问题
  • 原文地址:https://www.cnblogs.com/JustYong/p/4208869.html
Copyright © 2011-2022 走看看