示例#1
0
        public SafePrinter(string printerName) : base(true)
        {
            PRINTER_DEFAULTS defaults = default;

            defaults.DesiredPrinterAccess = PRINTER_ACCESS_MASK.PRINTER_ALL_ACCESS;

            if (NativeMethods.OpenPrinter(printerName, out var printerHandle, ref defaults) == 0)
            {
                throw new Win32Exception();
            }

            handle = printerHandle;
        }
示例#2
0
 internal static extern int OpenPrinter(string pPrinterName, out IntPtr phPrinter, ref PRINTER_DEFAULTS pDefault);