CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    [RESOLVED] Printers via C#

    Hi !

    How can I find out which printers are available using C#. I need to know which printers are installed on my machine. Thats needed to fill a list with all the printers available so I can select one of them for some specific print job. Or do I need to use API calls. Thx for any help.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,284

    Re: Printers via C#

    3 Ways I know of :

    1) EnumPrinters API

    2) PrinterSettings.InstalledPrinters

    3) WMI using ManagementObjectSearcher which can be something like :
    Code:
    { 
        // This connects to the WMI interface 
        ManagementScope scope = new ManagementScope("root\\default"); 
        scope.Connect(); 
        
        // This is the actual SQL Statement to get the printers. There is a whole set of classes and such on the WMI interface 
        ManagementObjectSearcher search = new ManagementObjectSearcher("Select * from win32_printer"); 
        
        ManagementObject printer; 
        foreach ( printer in search.Get()) { 
            
            // Do what you need to here 
            
        } 
    }
    I hope my post was helpful

  3. #3
    Join Date
    Mar 2005
    Location
    Vienna, Austria
    Posts
    4,538

    Re: Printers via C#

    Quote Originally Posted by HanneSThEGreaT
    ...I hope my post was helpful
    You saved my day Thx a lot Hannes.
    Jonny Poet

    To be Alive is depending on the willingsness to help others and also to permit others to help you. So lets be alive. !
    Using Code Tags makes the difference: Code is easier to read, so its easier to help. Do it like this: [CODE] Put Your Code here [/code]
    If anyone felt he has got help, show it in rating the post.
    Also dont forget to set a post which is fully answered to 'resolved'. For more details look to FAQ's about Forum Usage. BTW I'm using Framework 3.5 and you ?
    My latest articles :
    Creating a Dockable Panel-Controlmanager Using C#, Part 1 | Part 2 | Part 3 | Part 4 | Part 5 | Part 6 | Part 7

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured