/// <summary>
        /// Open a printer or server.
        /// </summary>
        /// <param name="printer_name">The name of the printer or server. If this is null or empty then it's the local server.</param>
        /// <param name="desired_access">The desired access on the printer.</param>
        /// <param name="throw_on_error">True to throw on error.</param>
        /// <returns>The opened printer.</returns>
        public static NtResult <PrinterObject> OpenPrinter(string printer_name, PrintSpoolerAccessRights desired_access, bool throw_on_error)
        {
            PRINTER_DEFAULTS defs = new PRINTER_DEFAULTS();

            defs.DesiredAccess = desired_access;
            return(PrintingNativeMethods.OpenPrinter(printer_name, out IntPtr handle, defs).CreateWin32Result(throw_on_error, () => new PrinterObject(handle, printer_name)));
        }
Example #2
0
 public static extern bool OpenPrinter(
     string pPrinterName,
     out IntPtr phPrinter,
     PRINTER_DEFAULTS pDefault
     );