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; }
internal static extern int OpenPrinter(string pPrinterName, out IntPtr phPrinter, ref PRINTER_DEFAULTS pDefault);