Click to See Complete Forum and Search --> : Monitoring printers


aneesh.joy
March 22nd, 2006, 12:31 AM
Hi all,

I have a print monitoring application that monitors available printers
while it starts. Its working fine.:)

Now I want to improve it to monitor newly added printers while its running.

I tried collecting available printers at 1 sec interval. But that does not
seem to be the right method.

Is there any other alternatives ? Any window messages ?

What I m basically looking for is some kind of callback or WM_*
that can get me the name of the newly added printer.

Cheers.

aneesh.joy
March 22nd, 2006, 04:06 AM
I found a solution for this.

Open local print server with OpenPrinter(NULL, &hPrinter, NULL)
and get notification handle on it using FindFirstPrinterChangeNotification

This was the clue ! :)

Then wait on the notification handle. When a new printer is added we will get printer information from it with FindNextPrinterChangeNotification
method.

That has PRINTER_NOTIFY_FIELD_PRINTER_NAME now we can get handle to the newly opened printer and monitor it.

Cheers.