PrintJob.PrinterName only returns first character in PrintJob_Added event

May 5, 2009 at 10:15 AM

Hi,

I wanted to upgrade the PrinterQueueWatch component from
version 2.0.4.33229 to version 2.0.6.38351 but have noticed
that the PrintJobEventArgs.PrintJob doesn't report the correct
UserName, PrinterName, DocumentName, etc., that is, it will
only return the first character of the string and cuts off
the rest.

For example if I want to monitor the printer: "TestPrinter"
the e.PrintJob.PrinterName returns only "T" (the first character)
in the printJob_Added(object obj, PrintJobEventArgs e) event.

The same code works well with the previous version.

Can you reproduce this behaviour?
And what is the latest stable version for production?

Thank you!

Best regards,
Johann

Coordinator
May 5, 2009 at 10:46 PM
Yup - the switch to unicode API calls basically broke it :-(
I'm still working out what to do to fix it - all assistance gratefully received - but if you take the 2.06.x code and turn the API declaratiuons back to ANSI it works...

2.0.4.x is your best bet for a production app. for now.
May 13, 2009 at 10:30 AM

Hi again,

first of all thank you for your answer.

Finally I had the time to debug the code and I have seen the
cause of the problem occurs in the PrinterNotifyInfo constructor.

'\\ this will only return the first letter
.InitPrinterName = item.ToString

'\\ this will only return the first letter too
.InitPrinterName = Marshal.PtrToStringAnsi(itemdata.pBuff)

'\\ working: this will return the correct name
.InitPrinterName = Marshal.PtrToStringUni(itemdata.pBuff)


But I haven't tested yet if this modification is save and recommended.

Best regards,
Johann

PS: Is the pJThis.InitPrinterName even neccessary because the
PrinterName property already contains the correct name before
the switch statement?

 

Coordinator
May 13, 2009 at 9:46 PM

Looks good so far!  Thanks