Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

WPF set default printer

Posted on 2011-09-26
4
691 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
ID: 36600167
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
ID: 36600223
I don't see ManagementObjectSearcher after importing
Imports System.Management.Instrumentation
Imports System.Management
0
 
LVL 3

Expert Comment

by:anjos
ID: 36600309
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
ID: 36600317
I got it to work now.  Thank you
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
get column names from table in vb.net 8 51
Sending receiving text messages in vb.net 15 48
vb.net and creating a class 5 20
Code enhancement 4 22
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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