Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / March 2008

Tip: Looking for answers? Try searching our database.

How to change default printer using c#.net?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Andrew - 26 Mar 2008 19:58 GMT
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.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.