Quantcast
Channel: PrintQueueWatch printer monitoring component
Viewing all 103 articles
Browse latest View live

Reopened Issue: System structures too small [7629]

$
0
0
We're using PrintQueueWatch in a service to obtain notification of and job information for jobs submitted to our data center for printing. However, we're seeing exceptions in the trace log indicating the size of a system structure is too small. For example,
 
PrinterQueueWatch.PrintJob: System.ComponentModel.Win32Exception: The data area passed to a system call is too small
at PrinterQueueWatch.SpoolerStructs.JOB_INFO_1..ctor(IntPtr hPrinter, Int32 dwJobId)
at PrinterQueueWatch.PrintJob.InitJobInfo()
 
and
 
PrinterQueueWatch.PrintJob: System.ComponentModel.Win32Exception: The data area passed to a system call is too small
at PrinterQueueWatch.SpoolerStructs.JOB_INFO_2..ctor(IntPtr hPrinter, Int32 dwJobId)
at PrinterQueueWatch.PrintJob.InitJobInfo()
 
I'm not sure how to proceed to resolve these issues. Can anyone offer any advice?
 
Thanks,
Pete Anfinsen
HealthPartners

Reopened Issue: Issue with PrintWatchQueue on 64 bit systems [4640]

$
0
0
Hello!
 
I have been trying to use the PrintWatchQueue component, but I have been running into an odd issue... When adding any printer using the .AddPrinter method I receive the following error:
 
Attempted to read or write protected memory. this is often an indication that other memory is corrupt.
 
I was using the latest version of the component (2.0.7.0) on a WindowsXP 64 box, Visual Studio 2005. When I tried to open the source code, I discovered it was written in VS 2008. Thinking that it might be a problem with the target CPU, I loaded the source code in a Server 2008 (32 bit)/VS 2008 virtual machine that I have. I checked - the target CPU was set to "Any CPU", so that wasn't the problem...
 
I recompiled anyhow, and copied the new dll back to my application on the 64 bit machine. Ran the program - encountered the same error. I then switched gears, and moved my app to the virtual machine. Converted the project to VS2008, compiled and ran it - BINGO! No error! Interesting - is this a 32 bit vs. 64 bit Framework issue? On to further investigation...
 
I needed to debug your source code to identify the location of the error, but the only source I had was VS 2008. So, I dug around a bit on MerrionComputing.com and on the CodePlex PUMA site. I found that the PrintQueueWatch code in the PUMA source was VS 2005. I recompiled the code, replaced the dll in my app, and was able to establish debugging. Here is what I found:
 
When I call the .AddPrinter method, the code executes successfully through creating a New PrinterInformation class when the DesiredAccess is set to 131080, but when it tries to create the class with DesiredAccess set to PrinterAccessRights.PRINTER_ALL_ACCESS (983052) the code throws theprotected memory error.
 
So there is the source of the error, but my knowledge of the Printer world is much too limited for me to make any sense of it. Do you have any ideas?
 
Thanks,
 
Eric

Reopened Issue: Alter PRINTER_INFO_2 to move the DEVMODE [978]

$
0
0
The PRINTER_INFO_2 structure size is too big because of a local variable to DEVMODE.
This needs to be factored out into a new superclass so that Marshal.SizeOf(PRINTER_INFO_2) returns the expected result.

New Post: IP/Network Printers

$
0
0
Here is what I did to monitor printed documents on all printers, including local and network/IP printers that have been installed on the local computer:

Imports PrinterQueueWatch

Public Class Form1
private withevents pmon as new printermonitorcomponent

Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
For Each p As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters
        pmon.AddPrinter(p)
    Next
end sub

Private Sub pmon_JobAdded(ByVal sender As Object, ByVal e As PrintJobEventArgs) Handles pmon.JobAdded
    msgbox(Now & " - " & e.PrintJob.Document.ToString & " was printed.")
End Sub
End Class

Hope this helps.

New Post: IP/Network Printers

$
0
0
I think that if you want to monitor an IP printer you have to be either (a) on the print server [if one is set up] or (b) on the machine issuing the print job. I don't think the IP printer broadcasts messages to all across the whole subnet?

New Post: Monitor all print queues computer

$
0
0
Can you please post the code.

I tried this but didn't get the success.
PrintMonitor[] objPrint = new PrintMonitor[2];

It has 

        public string DLLName { get; }
        public string Environment { get; }
        public string Name { get; }

New Post: Monitor all print queues computer

$
0
0
Vishal230 wrote:
Can you please post the code.

I tried this but didn't get the success.
PrintMonitor[] objPrint = new PrintMonitor[2];

It has 

        public string DLLName { get; }
        public string Environment { get; }
        public string Name { get; }

Created Unassigned: Not get PrintJob Information [10283]

$
0
0
When running the console version of my application on Windows 8 to capture print job information the printqueuewatch dll works a well.

When I put that same code into a service and run it in on windows 8, I don not get any print job information and the print job remains paused in my print queue.

Any help would be greatly appreciated.

New Post: Monitor all print queues computer

$
0
0
For monitoring more than one printer don't set the DeviceName properety - use the Addprinter method.

One component instance can monitor many printers...

New Post: Number of Copies and Page Count

$
0
0
Hi Merrion,

how to count only the pages that have been printed if the user cancels or delete
printing the print queue, I do not want to tell the final amount.
in which event I can do this?

New Post: Number of Copies and Page Count

$
0
0
I think that if the user cancels or deletes a print job the JobSet event will be fired.

In this event, check the PrintJob.Deleted property ... and the PrintJob.PagesPrinted should have the actual number of pages printed.

New Post: Number of Copies and Page Count

$
0
0
Hi Merrion,

Sorry for the delay in replying, I am using this code and everything is working
perfectly
Imports PrinterQueueWatch
Public Class Form1

    Private WithEvents pmc As New PrinterMonitorComponent 
    
    Private Sub pmc_JobDeleted(sender As System.Object, e As PrinterQueueWatch.PrintJobEventArgs) Handles pmc.JobDeleted
        Me.CapturaLogImpressao(sender, e)
    End Sub


    Private Sub CapturaLogImpressao(sender As System.Object, e As PrinterQueueWatch.PrintJobEventArgs)
        Try
            With CType(e, PrintJobEventArgs).PrintJob
                Me.ta.Insert(
                    .PrinterName,
                    .UserName,
                    .Document,
                    .TotalPages,
                    .Copies,
                    .PagesPrinted,
                    .Copies * .PagesPrinted,
                    .Printed,
                    .Submitted,
                    .MachineName,
                    .StatusDescription,
                    .Color,
                    .DriverName,
                    .Landscape,
                    .NotifyUserName,
                    .PaperSource.ToString,
                    .Position,
                    .PrinterResolutionKind.ToString,
                    .PrintProcessorName,
                    .PaperKind.ToString,
                    .PaperLength,
                    .PaperWidth
                    )
            End With
        Catch ex As Exception
            Me.CapturaRegistroPendente(sender, e)
            Me.CapturaLogErro(ex, "CapturaLogImpressao")
        End Try
    End Sub 
    
End Class
however I need to capture the number of pages printed when the user cancels the
Printing, e.g.

User A sent a document to the printer with the following settings

copies = 1
number of pages = 500

User canceled when printer had printed 200 pages, but
with the code I'm using I'm capturing 500 pages but user only printed 200 pages

Please post a code example of how to solve this problem?

Thank you for your help.

Commented Issue: Issue with PrintWatchQueue on 64 bit systems [4640]

$
0
0
Hello!
 
I have been trying to use the PrintWatchQueue component, but I have been running into an odd issue... When adding any printer using the .AddPrinter method I receive the following error:
 
Attempted to read or write protected memory. this is often an indication that other memory is corrupt.
 
I was using the latest version of the component (2.0.7.0) on a WindowsXP 64 box, Visual Studio 2005. When I tried to open the source code, I discovered it was written in VS 2008. Thinking that it might be a problem with the target CPU, I loaded the source code in a Server 2008 (32 bit)/VS 2008 virtual machine that I have. I checked - the target CPU was set to "Any CPU", so that wasn't the problem...
 
I recompiled anyhow, and copied the new dll back to my application on the 64 bit machine. Ran the program - encountered the same error. I then switched gears, and moved my app to the virtual machine. Converted the project to VS2008, compiled and ran it - BINGO! No error! Interesting - is this a 32 bit vs. 64 bit Framework issue? On to further investigation...
 
I needed to debug your source code to identify the location of the error, but the only source I had was VS 2008. So, I dug around a bit on MerrionComputing.com and on the CodePlex PUMA site. I found that the PrintQueueWatch code in the PUMA source was VS 2005. I recompiled the code, replaced the dll in my app, and was able to establish debugging. Here is what I found:
 
When I call the .AddPrinter method, the code executes successfully through creating a New PrinterInformation class when the DesiredAccess is set to 131080, but when it tries to create the class with DesiredAccess set to PrinterAccessRights.PRINTER_ALL_ACCESS (983052) the code throws theprotected memory error.
 
So there is the source of the error, but my knowledge of the Printer world is much too limited for me to make any sense of it. Do you have any ideas?
 
Thanks,
 
Eric
Comments: ** Comment from web user: vasu_i **

I guess this is a dead thread and the updated code didnt make it here.

New Post: Problem with the printer queue monitor component and network remote printers

$
0
0
Hello , we are having problems with the monitoring of jobs sent to a network printer . This is not true in all cases as we have found occasions where the submissions are monitored properly and others in which no events are received for jobs .
After studying the scenarios , we find the cause and we have taken it clear that:

1 - do not believe it user permissions issue since the same user , connected to a printer , manages to get the event well in a team and bad in another.
2 - Do not think it is problem of printer settings for the same reason as above .
3 - suspect it's a problem of soft installed on the computer , but we could not find the reason why in certain machines not receive these events.
4 - If at discharge network printer , we do as local queue to the machine, the problem does not reproduce.

Attached the log 's collected in or position you have the issue.

Can you think of something we can check ?

Greetings and thank you very much for your interest .

LOG's:

-- Printer Monitor Component -----------------
Started : martes, 15 de octubre de 2013
Version : 1.0.0.0

PrinterQueueWatch.PrinterMonitorComponent: AddPrinter(\simp\HP LaserJet 4250 PCL 6)
PrinterQueueWatch.PrinterInformation: InitPrinterInfo()
PrinterQueueWatch.PrinterInformation: InitPrinterInfo()
PrinterQueueWatch.EventQueue: New()
PrinterQueueWatch.EventQueue: StartWatching created new EventQueueWorker
PrinterQueueWatch.PrinterInformation: Monitored set to : True
PrinterQueueWatch.EventQueue: New()
PrinterQueueWatch.EventQueue: StartWatching created new EventQueueWorker
PrinterQueueWatch.PrinterChangeNotificationThread: StartWatching created new thread: PrinterChangeNotificationThread:1905004
PrinterQueueWatch.PrinterChangeNotificationThread: StartThread() of printer handle :1905004
PrinterQueueWatch.PrinterInformation: Dispose()
PrinterQueueWatch.PrinterNotifyOptions: New(False)
PrinterQueueWatch.PrinterNotifyOptionsType: New(False)
PrinterQueueWatch.PrinterNotifyOptionsType: SetupFields()
PrinterQueueWatch.PrinterChangeNotificationThread: StartWatch: FindFirstPrinterChangeNotification succeeded - handle: Microsoft.Win32.SafeHandles.SafeWaitHandle for printer handle: 1905004
PrinterQueueWatch.PrinterChangeNotificationThread: DecodePrinterChangeInformation() for printer handle: 1905004
PrinterQueueWatch.PrinterChangeNotificationThread: FindNextPrinterChangeNotification did not return a pointer to PRINTER_NOTIFY_INFO - the change flag was:65535
PrinterQueueWatch.EventQueue: Printer event enqueued
PrinterQueueWatch.EventQueue: Event queue awakened - 1 events
PrinterQueueWatch.EventQueue: Printer event dequeued
PrinterQueueWatch.EventQueue: Printer event returned
PrinterQueueWatch.PrinterChangeNotificationThread: DecodePrinterChangeInformation() for printer handle: 1905004
PrinterQueueWatch.PrinterChangeNotificationThread: FindNextPrinterChangeNotification did not return a pointer to PRINTER_NOTIFY_INFO - the change flag was:65535
PrinterQueueWatch.EventQueue: Printer event enqueued
PrinterQueueWatch.EventQueue: Event queue awakened - 1 events
PrinterQueueWatch.EventQueue: Printer event dequeued
PrinterQueueWatch.EventQueue: Printer event returned
PrinterQueueWatch.PrinterChangeNotificationThread: DecodePrinterChangeInformation() for printer handle: 1905004
PrinterQueueWatch.PrinterChangeNotificationThread: FindNextPrinterChangeNotification did not return a pointer to PRINTER_NOTIFY_INFO - the change flag was:65535
PrinterQueueWatch.EventQueue: Printer event enqueued
PrinterQueueWatch.EventQueue: Event queue awakened - 1 events
PrinterQueueWatch.EventQueue: Printer event dequeued
PrinterQueueWatch.EventQueue: Printer event returned
PrinterQueueWatch.PrinterInformation: Monitored set to : False
PrinterQueueWatch.PrinterInformation: Stop monitoring _NotificationThread : PrinterQueueWatch.PrinterChangeNotificationThread handle is valid
PrinterQueueWatch.PrinterChangeNotificationThread: CancelWatching()
PrinterQueueWatch.PrinterChangeNotificationThread: StartThread: Cancelled monitoring raised an event 1905004
PrinterQueueWatch.PrinterChangeNotificationThread: PrinterNotificationThread loop ended
PrinterQueueWatch.PrinterInformation: Dispose()
PrinterQueueWatch.PrinterChangeNotificationThread: Dispose()
PrinterQueueWatch.PrinterChangeNotificationThread: CancelWatching()
PrinterQueueWatch.PrinterNotifyOptions: Dispose()
PrinterQueueWatch.EventQueue: Dispose()
PrinterQueueWatch.EventQueue: EventQueue loop ended

New Post: Does this library support pause- resume facility.

$
0
0
I have a scenario here where i am monitoring a printer. What happens is when a job is added to a printer it is pause, and only resume after a user action.

OS what i have done is i have added the into a list view. Now i need to invoke a print job from the listview and resume it or delete it.

Prat of the code is below.

Public WithEvents pmon As New PrinterMonitorComponent
Private Delegate Sub AddListViewItemDelegate(ByVal lv As ListView, ByVal lvItem As ListViewItem)

Private Sub AddListViewItem(ByVal lv As ListView, ByVal lvItem As ListViewItem)

    If lv.InvokeRequired Then
        lv.Invoke(New AddListViewItemDelegate(AddressOf AddListViewItem), New Object() {lv, lvItem})
    Else
        lv.Items.Add(lvItem)
    End If

End Sub

Private Delegate Sub RemoveListViewItemDelegate(ByVal lv As ListView, ByVal lvItem As ListViewItem)

Private Sub RemoveListViewItem(ByVal lv As ListView, ByVal lvItem As ListViewItem)

    If lv.InvokeRequired Then
        lv.Invoke(New RemoveListViewItemDelegate(AddressOf AddListViewItem), New Object() {lv, lvItem})
    Else
        lv.Items.Remove(lvItem)
    End If

End Sub

Public Sub New()
    MyBase.New()

    ' This call is required by the Windows Form Designer.
    InitializeComponent()

    ' Monitor all the installed printers 
    pmon.MonitorJobAddedEvent = True
    pmon.MonitorJobDeletedEvent = True
    pmon.MonitorJobSetEvent = True
    pmon.MonitorJobWrittenEvent = True

    For Each p As String In System.Drawing.Printing.PrinterSettings.InstalledPrinters

        pmon.AddPrinter(p)
        pmon.PrinterInformation(p).PauseAllNewJobs = True


    Next p




End Sub

Private Sub pmon_JobAdded(ByVal sender As Object, ByVal e As PrintJobEventArgs) Handles pmon.JobAdded
    Try
        Dim lvitem As ListViewItem = New ListViewItem

        With CType(e, PrintJobEventArgs)
            lvitem.SubItems.Clear()
            lvitem.Text = Nothing

            With .PrintJob
                lvitem.Text = .JobId
                lvitem.SubItems.Add(.MachineName)
                lvitem.SubItems.Add(.UserName)
                lvitem.SubItems.Add(.PrinterName)
                lvitem.SubItems.Add(.TotalPages)
                lvitem.SubItems.Add(.StatusDescription)
                lvitem.SubItems.Add(.Priority)

            End With

            AddListViewItem(ListView1, lvitem)


            ' ListView1.Items.Remove(lvitem)
            Trace.WriteLine("New job added " & .PrintJob.UserName)

        End With
    Catch ex As Exception
        MessageBox.Show(ex.Message)

    End Try
End Sub

So i need to select a job then send a action command, to the job in the printer. e.g like if Select Print the the job that job is printed.

Please help.

New Post: Does this library support pause- resume facility.

$
0
0
Hi Mugove

Were you able to resume a particular print job again.

If so, could you perhaps share how you have done it..

New Post: Does this library support pause- resume facility.

New Post: Tranfer problem...

$
0
0
I am development a aplication to monitor print queues from server and i want to transfer jobs from on printer to another if some condition are true (and if the printer driver is the same).

For that i am using Transfer method, but i am getting a error "Access is denied" on Transfer method call. It seems that is on OpenPrinter Method.

What i need to setup on PrinterMonitorComponent??
This is the code to start listen the printers from my server.
foreach (PrinterInformation p in new PrinterInformationCollection())
            {
                pmon.AddPrinter(p.PrinterName);                              
                Console.WriteLine(string.Format("Printer {0} added to monitor", p.PrinterName));
            }
My Job add event:
private void printerMonitorComponent1_JobAdded(object sender, PrintJobEventArgs args)
{
    Console.WriteLine(string.Format("Job start on printer {0} user {1}", args.PrintJob.PrinterName,
        args.PrintJob.UserName));
    try
    {
        //PrinterDriver

        args.PrintJob.Transfer("Printer teste", true);
    }
    catch (Exception ex)
    {
        throw;
    }
    
}

New Post: Tranfer problem...

$
0
0
It is calling OpenPrinter with:-

Dim pDefault As New PRINTER_DEFAULTS(PrinterAccessRights.PRINTER_ACCESS_USE)

Is it failing when opening the target printer ("Printer teste") ?

New Post: Tranfer problem...

$
0
0
Yes, thats correct. I know its a permission issue, i already have changed the type of permission PrinterAccessRights to several values,
but the result is always the same.
Viewing all 103 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>