locked
FindNextPrinterChangeNotification with PRINTER_NOTIFY_OPTIONS_REFRESH fails RRS feed

  • Question

  • I'm having trouble with printer change notifications for shared printers on Windows Vista (possibly other platforms).

    1: PrinterName is a UNC path to a shared network printer: \\DomainName\ShareName
    2: The identity running the process has access to the printer and print jobs submitted by the process complete successfully.
    3: OpenPrinter succeeds, with the PRINTER_ACCESS_USE access flag
    4: FindFirstPrinterChangeNotification succeeds with my desired Job and Printer notification options and returns a "valid" notification handle
    5: I wait on a manual reset event, which is signalled regularly (every 5 sec or so)
    6: Calling FindNextPrinterChangeNotification after being signalled succeeds, but returns PRINTER_NOTIFY_INFO_DISCARDED
    7: Result from 6 indicates that PRINTER_NOTIFY_OPTIONS_REFRESH is required, calling FindNextPrinterChangeNotification again with that flag fails and the Win32 error message is 6: ERROR_INVALID_HANDLE.

    The same code works correctly when a local printer is used (with either a USB or IP port). Code fails with the same printers (HP and Canon) using the UNC path (direct to shared printer). It works if I add a local printer on a Local Port pointing to the UNC path.

    I tested the PrintMon sample (PrintJob.exe) against the same path and printers and when I enable 'Use Printer Notifications' the results are the same: PrintJob displays an error prompt with the message "The handle is invalid" and 'FindNextPrinterChangeNotification' as the window title.

    So I guess my question is, are printer notifications intended to work with shared printers or is this 'Invalid Handle' error expected? The Local Port solution works, but I don't get many useful notifications as the local print queue doesn't fail for things like offline printers or out of paper. It just delivers it's job to the upstream queue and calls it a day.

    Thanks for any information,
    Mike

    Edited to add
    I forgot to mention that when I add the same printers to the Vista machine as 'network' printers and I open the print queue in Explorer, the titlebar occassionally blinks 'Refreshing'. This seems to indicate that explorer knows it has to poll the network printer rather than using notifications.
    • Edited by Haboustak Tuesday, June 17, 2008 10:36 PM Added detail
    • Moved by Yan-Fei Wei Tuesday, June 24, 2008 9:57 AM off-topic of C++
    Tuesday, June 17, 2008 10:28 PM

All replies

  • Dear Haboustak,

    Thanks for participating on the MSDN Forum! I think your question is mainly related to Windows printer function, but not Visual C++. Thus, I suggest you post your question on the win32.programmer.gdi newsgroup, there you find windows printing experts and your question should be answered in no time.

    The people there will have enough experience with FindNextPrinterChangeNotification to give you the best advice or answer!

    Please post your question at

    http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.win32.programmer.gdi&lang=en&cr=US

     

    Thanks!


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, June 24, 2008 9:56 AM
  • Haboustak ,


    Were you able to find a solution for this? I am getting exactly the same problem: http://social.msdn.microsoft.com/Forums/en-US/windowsgeneraldevelopmentissues/thread/3380c0ba-8627-47e0-aeff-97b95c4a35c0

    Saturday, March 12, 2011 9:22 AM
  • Nevermind. I have found a solution.

     

    Thank you,

    Volodymyr.

    Monday, June 20, 2011 1:26 PM
  • Please share! I never found a solution, I gave up on it.
    Friday, June 29, 2012 3:17 PM
  • Volodymyr, I know that this is an old discussion, but can you share the solution for this problem? I'm facing it right now. Thank you!
    Thursday, January 2, 2014 7:41 AM