Search code examples
windowsnotificationsspooler

Sample code for Windows RegisterForPrintAsyncNotifications in the Spooler API?


Windows Vista introduced notifications from the Printer Spooler with the RegisterForPrintAsyncNotifications function (http://msdn.microsoft.com/en-us/library/dd162919(VS.85).aspx)

Does anyone know of any sample code for spooler notifications using that function? I have been unable to find any and it seems strange that Microsoft would publish the method without examples.


Solution

  • The Windows WDK 8.1 contains a sample VS solution that demonstrates the async API. But it's not part of the Win10 WDK. The solution builds two projects:

    • a static library that you can link with your port monitor or printer driver and which broadcasts notifications
    • a client app that receives the notifications and pops message boxes or balloon UI from the system tray.

    You should probably also check this MS Japanese article which lists the steps required to call the static library api from your existing code.