private bool AddPdfScribePrinter()
        {
            bool           printerAdded     = false;
            PRINTER_INFO_2 pdfScribePrinter = new PRINTER_INFO_2();

            pdfScribePrinter.pServerName     = null;
            pdfScribePrinter.pPrinterName    = PRINTERNAME;
            pdfScribePrinter.pPortName       = PORTNAME;
            pdfScribePrinter.pDriverName     = DRIVERNAME;
            pdfScribePrinter.pPrintProcessor = PRINTPROCESOR;
            pdfScribePrinter.pDatatype       = "RAW";
            pdfScribePrinter.Attributes      = 0x00000002;

            int pdfScribePrinterHandle = NativeMethods.AddPrinter(null, 2, ref pdfScribePrinter);

            if (pdfScribePrinterHandle != 0)
            {
                // Added ok
                int closeCode = NativeMethods.ClosePrinter((IntPtr)pdfScribePrinterHandle);
                printerAdded = true;
            }
            else
            {
                logEventSource.TraceEvent(TraceEventType.Error,
                                          (int)TraceEventType.Error,
                                          "Could not add PDF Scribe virtual printer. " +
                                          String.Format(WIN32ERROR, Marshal.GetLastWin32Error().ToString()));
            }
            return(printerAdded);
        }
Example #2
0
 internal static extern int AddPrinter(string pName, uint Level, [In] ref PRINTER_INFO_2 pPrinter);