Solved

WPF set default printer

Posted on 2011-09-26
4
646 Views
Last Modified: 2012-05-12
How can I set a specific printer to default printer in WPF?
0
Comment
Question by:VBdotnet2005
  • 2
  • 2
4 Comments
 
LVL 3

Accepted Solution

by:
anjos earned 125 total points
Comment Utility
see here:
http://stackoverflow.com/questions/6388503/change-default-printer-within-wpf-application

var query = new ManagementObjectSearcher("SELECT * FROM Win32_Printer"); 
var printers = query.Get();
string printerName = "Printer to set as default" ;
foreach(ManagementObject printer in printers) 
{ 
   if (printer["name"].ToString() == printerName.ToString()) 
   { 
      printer.InvokeMethod("SetDefaultPrinter", new object[] { printerName }); 
   } 
}

Open in new window

0
 

Author Comment

by:VBdotnet2005
Comment Utility
I don't see ManagementObjectSearcher after importing
Imports System.Management.Instrumentation
Imports System.Management
0
 
LVL 3

Expert Comment

by:anjos
Comment Utility
and if you try this:
http://stackoverflow.com/questions/3692384/missing-directive-or-assembly-reference-using-wmi-managementobjectsearcher

"You will have to rightclick the project -> add reference and add the System.Management assembly"
0
 

Author Comment

by:VBdotnet2005
Comment Utility
I got it to work now.  Thank you
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now