internal override void GetPrintDialogInfo(string printer, ref string port, ref string type, ref string status, ref string comment) { IntPtr hPrn; PRINTER_INFO printer_info = new PRINTER_INFO(); int needed = 0; IntPtr ptr; Win32OpenPrinter(printer, out hPrn, IntPtr.Zero); if (hPrn == IntPtr.Zero) { return; } Win32GetPrinter(hPrn, 2, IntPtr.Zero, 0, ref needed); ptr = Marshal.AllocHGlobal(needed); Win32GetPrinter(hPrn, 2, ptr, needed, ref needed); printer_info = (PRINTER_INFO)Marshal.PtrToStructure(ptr, typeof(PRINTER_INFO)); Marshal.FreeHGlobal(ptr); port = Marshal.PtrToStringUni(printer_info.pPortName); comment = Marshal.PtrToStringUni(printer_info.pComment); type = Marshal.PtrToStringUni(printer_info.pDriverName); status = GetPrinterStatusMsg(printer_info.Status); Win32ClosePrinter(hPrn); }
internal override void GetPrintDialogInfo (string printer, ref string port, ref string type, ref string status, ref string comment) { IntPtr hPrn; PRINTER_INFO printer_info = new PRINTER_INFO (); int needed = 0; IntPtr ptr; Win32OpenPrinter (printer, out hPrn, IntPtr.Zero); if (hPrn == IntPtr.Zero) return; Win32GetPrinter (hPrn, 2, IntPtr.Zero, 0, ref needed); ptr = Marshal.AllocHGlobal (needed); Win32GetPrinter (hPrn, 2, ptr, needed, ref needed); printer_info = (PRINTER_INFO) Marshal.PtrToStructure (ptr, typeof (PRINTER_INFO)); Marshal.FreeHGlobal (ptr); port = Marshal.PtrToStringUni (printer_info.pPortName); comment = Marshal.PtrToStringUni (printer_info.pComment); type = Marshal.PtrToStringUni (printer_info.pDriverName); status = GetPrinterStatusMsg (printer_info.Status); Win32ClosePrinter (hPrn); }