Hello, friends,
We need to programmatically change default printer in our c#.net 2005
application. We tried:
System.Drawing.Printing.PrinterSettings oPS = new
System.Drawing.Printing.PrinterSettings();
try
{
oPS.PrinterName = defaultPrinterName;
}
catch (System.Drawing.Printing.InvalidPrinterException ix)
{
Console.WriteLine(ix.Message);
return false;
}
finally
{
oPS = null;
}
but, no luck. The thrid party applications, say MS Word/NotePad, still use
previous default printer, not the new specified one.
Any ideas? Thanks a lot.
Henning Krause [MVP - Exchange] - 26 Mar 2008 22:28 GMT
Hello,
I don't think this is supported by managed code - but I could be wrong.
Anyway, take a look at the Win32 SetDefaultPrinter method
(http://msdn2.microsoft.com/en-us/library/ms535468(VS.85).aspx). You can
call it using P/Invoke.
Kind regards,
Henning Krause
> Hello, friends,
>
[quoted text clipped - 22 lines]
>
> Any ideas? Thanks a lot.