Pablo, You can use WMI to get and set the default printer.
Example follows.
----
Ionic Shade
Microsoft Developer Division
// Printer.cs
//
// sets the default printer using WMI
//
// references:
//
http://msdn.microsoft.com/library/en...32_printer.asp
//
// Fri, 19 Sep 2003 14:14
//
public class PrinterTest {
public static void Main(string[] args) {
string PrinterToSelect = null;
if (args.Length>0) {
if (!(args[0].StartsWith("-")))
PrinterToSelect = args[0];
else {
System.Console. WriteLine("\nTh is utility lists the configured
printers, and optionally selects\na new default printer.\n");
System.Console. WriteLine("usag e: Printer [<name of printer to
select as default>]");
return ;
}
}
// Get the list of configured printers:
string strQuery= "SELECT * FROM Win32_Printer";
System.Console. WriteLine("WMI Query: '{0}'", strQuery);
System.Console. WriteLine("==== =============== =============== ============");
System.Manageme nt.ObjectQuery oq = new
System.Manageme nt.ObjectQuery( strQuery);
System.Manageme nt.ManagementOb jectSearcher query1 = new
System.Manageme nt.ManagementOb jectSearcher(oq );
System.Manageme nt.ManagementOb jectCollection queryCollection 1 =
query1.Get();
System.Manageme nt.ManagementOb ject newDefault= null;
foreach( System.Manageme nt.ManagementOb ject mo in queryCollection 1 ) {
System.Manageme nt.PropertyData Collection pdc = mo.Properties;
System.Console. WriteLine("'{0} '", mo["Name"]);
if ((bool)mo["Local"])
System.Console. WriteLine(" A local printer");
else if ((bool)mo["Network"])
System.Console. WriteLine(" a network printer located at: {0}",
mo["Location"]);
// if you want to display all properties of every printer
// foreach (System.Managem ent.PropertyDat a pd in pdc) {
// System.Console. WriteLine(" {0:12} : {1}", pd.Name,
mo[pd.Name]);
// }
if ((bool)mo["Default"]) {
System.Console. WriteLine(" THIS IS THE DEFAULT PRINTER");
}
else if (mo["Name"].ToString().Tri m()==PrinterToS elect)
newDefault= mo; // store for later
System.Console. WriteLine("");
}
if (newDefault!=nu ll) {
System.Console. WriteLine("\nRE SETTING THE DEFAULT PRINTER to '{0}'",
newDefault["Name"]);
//Execute the method
System.Manageme nt.ManagementBa seObject outParams =
newDefault.Invo keMethod ("SetDefaultPri nter", null, null);
//Display results
//Note: The return code of the method is provided in the "returnValu e"
property of the outParams object
System.Console. WriteLine("SetD efaultPrinter() returned: " +
outParams["returnValu e"]);
}
}
}
"Pablo" <t-******@infocorp .com.uy> wrote in message
news:86******** *************** *****@phx.gbl.. .
Friends,
how can i get the name of the default printer??. I'm
working with winforms. VB,C#, nevermind.
Thanks a lot
Pablo