Hi,
There are three options I am aware of..
1) Using WMI and invoking the SetDefaultPrint er method on the Win32_Printer
object
2) Interop and call the Win32 API function SetDefaultPrint er
3) Manipulate the registry directly and sent a broadcast message to all
applications
In my opinion option one is the cleanest option from .NET followed by option
2 and option 3 is a last resort in the case where you need to support OS
prior to Windows 2000.
The following example will enumerate the printers using WMI and invoke the
SetDefaultPrint er method of each of the printers. For this you will need to
add a reference to the System.Manageme nt assembly.
System.Manageme nt.ManagementOb jectSearcher search;
System.Manageme nt.ManagementOb jectCollection results;
search = new System.Manageme nt.ManagementOb jectSearcher("s elect *
from win32_printer") ;
results = search.Get();
foreach (System.Managem ent.ManagementO bject printer in results)
{
System.Diagnost ics.Debug.Write Line(printer["Name"]);
printer.InvokeM ethod("SetDefau ltPrinter", null);
}
If you need more info on the other options, just post here.
Hope this helps
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"ThunderMus ic" <NOdanlatSPAM@h otmaildotcom> wrote in message
news:e6******** ******@TK2MSFTN GP12.phx.gbl...
hi,
Is there an easy way to change the default printer from .net?
thanks
ThunderMusic