EnumPrinters.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Enumerates printers installed in the system
  3. //
  4. using System;
  5. using System.Drawing.Printing;
  6. public class EnumPrinters
  7. {
  8. public static void Main (string[] args)
  9. {
  10. PrinterSettings.StringCollection col = System.Drawing.Printing.PrinterSettings.InstalledPrinters;
  11. for (int i = 0; i < col.Count; i++) {
  12. Console.WriteLine ("--- {0}", col[i]);
  13. PrinterSettings ps = new PrinterSettings ();
  14. ps.PrinterName = col[i];
  15. //Console.WriteLine (" Duplex: {0}", ps.Duplex);
  16. Console.WriteLine (" FromPage: {0}", ps.FromPage);
  17. Console.WriteLine (" ToPage: {0}", ps.ToPage);
  18. Console.WriteLine (" MaximumCopies: {0}", ps.MaximumCopies);
  19. Console.WriteLine (" IsDefaultPrinter: {0}", ps.IsDefaultPrinter);
  20. Console.WriteLine (" SupportsColor: {0}", ps.SupportsColor);
  21. Console.WriteLine (" MaximumPage {0}", ps.MaximumPage);
  22. Console.WriteLine (" MinimumPage {0}", ps.MinimumPage);
  23. Console.WriteLine (" LandscapeAngle {0}", ps.LandscapeAngle);
  24. /*
  25. for (int p = 0; p < ps.PrinterResolutions.Count; p++) {
  26. Console.WriteLine (" PrinterResolutions {0}", ps.PrinterResolutions [p]);
  27. }*/
  28. for (int p = 0; p < ps.PaperSizes.Count; p++) {
  29. Console.WriteLine (" PaperSize Name [{0}] Kind [{1}] Width {2} Height {3}",
  30. ps.PaperSizes [p].PaperName, ps.PaperSizes [p].Kind,
  31. ps.PaperSizes [p].Width, ps.PaperSizes [p].Height);
  32. }
  33. }
  34. }
  35. }