Recipe 11.3. Get Details About the Default Printer


You need to know some of the settings for the default printer installed on the local workstation, such as its name and page size.


Create a PrintDocument object, and use it to access the details for the default printer:

 Dim justChecking As New System.Drawing.Printing.PrintDocument MsgBox(justChecking.PrinterSettings.PrinterName) 


In .NET, printer settings exist in the context of a document to print. The PrintDocument object includes a PrinterSettings member that fully describes the printer target of the document. When you create a new print document, .NET fills in the settings for the default printer on the local workstation. If you want to examine the settings for another installed printer, modify the PrinterSettings.PrinterName property to indicate the desired printer:

 With justChecking.PrinterSettings    .PrinterName = "AnotherPrinter"    If (.IsValid = True) Then       ' ----- Look at the other settings.    End If End With 

Visual Basic 2005 Cookbook(c) Solutions for VB 2005 Programmers
Visual Basic 2005 Cookbook: Solutions for VB 2005 Programmers (Cookbooks (OReilly))
ISBN: 0596101775
EAN: 2147483647
Year: 2006
Pages: 400 © 2008-2017.
If you may any questions please contact us: