none
How to get list of printers? RRS feed

  • Question

  • I need to get list of printers displayed in the "Devices and Printers".

    How to get it in C# .NET 2.0(VS2005)?

    



    • Edited by Jeff0803 Wednesday, December 12, 2018 8:25 PM
    Wednesday, December 12, 2018 8:12 PM

Answers

  • Wednesday, December 12, 2018 8:36 PM
  • Hi Jeff0803,

    Thank you for posting here.

    If you want to get the list of printers displayed in the "Devices and Printers", you could try the code below.

    static void Main(string[] args)
            {
    
                List<string> list = new List<string>();
                PrintDocument prtdoc = new PrintDocument();
    
               string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;
    
               foreach (String strPrinter in PrinterSettings.InstalledPrinters)
                {
                    list.Add(strPrinter);
                }
                foreach (var item in list)
                {
                    Console.WriteLine(item);
                }
                Console.ReadKey();
            }

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, December 13, 2018 2:53 AM
    Moderator

All replies

  • Wednesday, December 12, 2018 8:36 PM
  • Hi Jeff0803,

    Thank you for posting here.

    If you want to get the list of printers displayed in the "Devices and Printers", you could try the code below.

    static void Main(string[] args)
            {
    
                List<string> list = new List<string>();
                PrintDocument prtdoc = new PrintDocument();
    
               string strDefaultPrinter = prtdoc.PrinterSettings.PrinterName;
    
               foreach (String strPrinter in PrinterSettings.InstalledPrinters)
                {
                    list.Add(strPrinter);
                }
                foreach (var item in list)
                {
                    Console.WriteLine(item);
                }
                Console.ReadKey();
            }

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    Thursday, December 13, 2018 2:53 AM
    Moderator