/// <summary> /// Get Printer Info /// </summary> /// <param name="printer"></param> /// <returns></returns> public PRINTER_INFO_2 GetPrinter(Printer printer) { IntPtr pHandle; PRINTER_INFO_2 Info2 = new PRINTER_INFO_2(); PRINTER_DEFAULTS defaults = new PRINTER_DEFAULTS(); OpenPrinter(printer.Name, out pHandle, defaults); uint cbNeeded = 0; bool bRet = GetPrinter(pHandle, 2, IntPtr.Zero, 0, ref cbNeeded); if (cbNeeded > 0) { IntPtr pAddr = Marshal.AllocHGlobal((int)cbNeeded); bRet = GetPrinter(pHandle, 2, pAddr, cbNeeded, ref cbNeeded); if (bRet) { Info2 = (PRINTER_INFO_2)Marshal.PtrToStructure(pAddr, typeof(PRINTER_INFO_2)); } Marshal.FreeHGlobal(pAddr); } ClosePrinter(pHandle); return Info2; }
public PrinterInfo(Printer printer) { tooltip = new ToolTip(); InitializeComponent(); info = Main.Manager.GetPrinter(printer); }
public Main() { _man = new Manager(); InitializeComponent(); listPrinters.Items.AddRange(_man.Printers.ToArray()); listPrinters.ContextMenu = PrinterListContextMenu(); _selectedPrinter = listPrinters.Items[0] as Printer; }
public bool SetDefaultPrinter(Printer printer) { return SetDefaultPrinter(printer.Name); }
public bool FlushPrinter(Printer printer) { int i=0; var result = FlushPrinter(printer.Pointer,IntPtr.Zero,0,out i,1000); return result; }
/// <summary> /// Open printer's properties dialog /// </summary> /// <param name="printer"></param> /// <returns></returns> public int DocumentProperty(Printer printer) { return DocumentProperties(IntPtr.Zero, printer.Pointer, printer.Name, IntPtr.Zero, IntPtr.Zero, (fModes)14); }
private void listPrinters_SelectedIndexChanged(object sender, EventArgs e) { _selectedPrinter = ((ListBox)sender).SelectedItem as Printer; }