Network Printer

Sep 22, 2009 at 3:21 AM
  
' Code from the Sample
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ' Add any initialization after the InitializeComponent() call
        For Each p As PrinterInformation In New PrinterInformationCollection

            '  Does not pick up network printers (ipp = Novell iPrint)
            pmon.AddPrinter(p.PrinterName)
            Trace.WriteLine(String.Format("Printer {0} added to monitor", p.PrinterName))
            Me.TextBox1.Text += IIf(Me.TextBox1.Text.Length > 0, vbCrLf, String.Empty) + String.Format("Printer {0} added to monitor", p.PrinterName)
        Next p

        ' Try Monitor Network Printer as follow but failed: Invalid Printer Name
        pmon.AddPrinter("\\ipp://xxx.xxx.xxx.xx\ipp\HPLJ8000DN")
        Me.TextBox1.Text += IIf(Me.TextBox1.Text.Length > 0, vbCrLf, String.Empty) + String.Format("Printer {0} added to monitor", "HPLJ8000DN")

    End Sub

Hello,

I am trying the sample code, but can't get it to work with Novell iPrint, any Idea why?:

The above code work with Standard IP Port Printer.

eg:
Printer Name Show in windows XP: HPLJ8000DN on HAL (Where HAL = Novell Print Server Name)
Right Click and Select Properties on the Printer:
    The name is: HPLJ8000DN
    The ports is: ipp://xxx.xxx.xxx.xx/ipp/HPLJ8000DN

I've use Microsoft Word Macro to return the ActivePrinter Name:
    \\HAL\HPLJ8000DN on NE00:

Tried Printer Name in the following line of code:

1. Invalid Printer Name
        pmon.AddPrinter(\\ipp://xxx.xxx.xxx.xx\ipp\HPLJ8000DN)

2. This function is not supported on this system
        pmon.AddPrinter(\\HAL\HPLJ8000DN)

Error Occurred in PrinterChangeNotificationThread.vb

Private Sub StartThread()
..
        If _MonitorLevel = PrinterMonitorComponent.MonitorJobEventInformationLevels.MaximumJobInformation Or _MonitorLevel = PrinterMonitorComponent.MonitorJobEventInformationLevels.MinimumJobInformation Then
            Try
                mhWait = FindFirstPrinterChangeNotification( _
                                                            _PrinterHandle.ToInt32, _
                                                            _WatchFlags, _
                                                            0, _
                                                           _PrinterNotifyOptions)

            Catch e As Win32Exception
                If PrinterMonitorComponent.ComponentTraceSwitch.Level >= TraceLevel.Error Then
                    Trace.WriteLine(e.Message & " for printer handle: " & _PrinterHandle.ToString, Me.GetType.ToString)
                End If
            Catch e2 As Exception
                If PrinterMonitorComponent.ComponentTraceSwitch.TraceError Then
                    Trace.WriteLine(e2.Message & " for printer handle: " & _PrinterHandle.ToString, Me.GetType.ToString)
                End If
            Finally
                ' **************** ERROR REPORTED HERE *************
                If Not (mhWait Is Nothing) AndAlso mhWait.IsInvalid Then
                    If PrinterMonitorComponent.ComponentTraceSwitch.TraceError Then
                        Trace.WriteLine("StartWatch: FindFirstPrinterChangeNotification failed - handle: " & mhWait.ToString & " for printer handle: " & _PrinterHandle.ToString, Me.GetType.ToString)
                    End If
                    Throw New Win32Exception
                Else
                    If PrinterMonitorComponent.ComponentTraceSwitch.TraceError Then
                        Trace.WriteLine("StartWatch: FindFirstPrinterChangeNotification succeeded - handle: " & mhWait.ToString & " for printer handle: " & _PrinterHandle.ToString, Me.GetType.ToString)
                    End If
                End If
            End Try
Thanks in Advance.
Regards Dat. 

 

Sep 23, 2009 at 3:48 AM

I am now moving one step closer to the actual problem with the Help of Moroz, Val from E-Sight that the Printer Name should be: \\xxx.xxx.xxx.xx\HPLJ8000DN

Code By Val:

            System.Windows.Forms.PrintDialog prnDlg;

            prnDlg = new PrintDialog();

            DialogResult result = prnDlg.ShowDialog();

            // If the result is OK then show printer name

            if (result == DialogResult.OK)
            {

                MessageBox.Show("your prn name is " + prnDlg.PrinterSettings.PrinterName);

            }
Therefore the problem is now with FindFirstPrinterChangeNotification and the Novell iPrint Driver?
Any Idea?
Thanks in Advance.