Print (Port and Driver Name)

ss7thirty

Well-known member
Joined
Jun 14, 2005
Messages
455
Location
New Jersey, US
Programming Experience
5-10
The VB6 Printer Object contains Name,Port, Driver as properties. I find it hard to believe that .NET would drop functionality from VB6. how do I obtain this information in .NET 2.0? Here is some code:

VB.NET:
    Private Sub PopulatePrinters()
        For Each strPrinter As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
            cbPrinters.Items.Add(strPrinter)
        Next
        cbPrinters.Text = GetDefaultPrinterName()
    End Sub

I am printing a crystal report object and would like to have the user be able to select a printer and print to that printer. Am I stuck forcing them into PrintDialog to get those three things i need (name, port, driver)? If so that is ok I have just not even found a way to do it with PrintDialog as well.

Simply put I need get Port and DriverName of a printer. I posted a similar thread but was asking more about the CrystalReport object than just about getting this info from .NET. Because I am still not sure what that function is expecting.
 
I dont believe there is a quick way, but it is possible. The code you need is in :-

How to call the EnumJobs function from a Visual Basic .NET application

Part of the code:

VB.NET:
        PrinterStr = PrinterStr & "Printer Name = " & GetString(PI2.pPrinterName) & vbCrLf
        PrinterStr = PrinterStr & "Printer Driver Name = " & GetString(PI2.pDriverName) & vbCrLf
        PrinterStr = PrinterStr & "Printer Port Name = " & GetString(PI2.pPortName) & vbCrLf
 
Back
Top