Tranfer problem...

Jan 21, 2014 at 4:52 PM
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())
                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.Transfer("Printer teste", true);
    catch (Exception ex)
Jan 22, 2014 at 12:00 PM
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") ?
Jan 22, 2014 at 5:32 PM
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.
Jan 29, 2014 at 2:04 PM
Do you have any ideas what this could be?
I am running a windows 8 64 bits machine.
Feb 4, 2014 at 1:04 PM
I don't think it is anything to do with 64 bit.
More likely the "unique name" to get the job by is incorrect

Code is currently:-
#Region "UniquePrinterObject"
    ''' -----------------------------------------------------------------------------
    ''' <summary>
    ''' Returns the unique name of this job which can be passed to get a handle to it
    ''' </summary>
    ''' <returns>[PrinterNmae], PrintJob xxxxx </returns>
    ''' <remarks>Used internally for ReadPrinter api call
    ''' </remarks>
    ''' <history>
    '''     [Duncan]    05/12/2005  Created
    ''' </history>
    ''' -----------------------------------------------------------------------------
    Friend Function UniquePrinterObject() As String

        Return Me.PrinterName & ",Job " & Me.JobId.ToString

    End Function
#End Region
I think this may be incorrectly format - try formatting it to 4 digits (i.e. 0001 rather than 1) and maybe it requires a space before the ,Job ?
Feb 4, 2014 at 1:31 PM
Ah - per StackOverflow there must be a space before "Job" and also pass NULL for pDefault.