Discussion:
Notification if a new printer is installed
(too old to reply)
Frank
2014-07-16 06:54:31 UTC
Permalink
Dear people,

is it possible to receive in an MFC program
a message if a new printer is installed or
deleted? Or does the frame window(?) already
receive one that I could catch in this case?
Or is there a different way of "sniffing"
for that? I tried to google "system notification"
but to no success.

TIA!
David Lowndes
2014-07-16 08:41:13 UTC
Permalink
Post by Frank
is it possible to receive in an MFC program
a message if a new printer is installed or
deleted?
Have a look at the FindNextPrinterChangeNotification API with
PRINTER_CHANGE_ADD_PRINTER.
Post by Frank
Or does the frame window(?) already
receive one that I could catch in this case?
Have you tried using Spy++ to see if there is any - there may well be
a WM_SETTINGCHANGE notification.

Dave
Frank
2014-07-16 09:20:57 UTC
Permalink
Post by David Lowndes
Have you tried using Spy++ to see if there is any - there may well be
a WM_SETTINGCHANGE notification.
Thank you - the main window indeed receives a
WM_SETTINGCHANGE, both when installing and
deleting a printer. Now another question -
is there a way to provoke a messsage box to
the user when he installs a printer? The
background is, I'd like to test whether the
message really does not arrive until the
user has "clicked away" all message boxes
so the printer is really completely installed.
I'm using mostly network printers, so
maybe I could provoke a small "problem"
with access rights or something?
David Lowndes
2014-07-16 10:01:47 UTC
Permalink
Post by Frank
Post by David Lowndes
Have you tried using Spy++ to see if there is any - there may well be
a WM_SETTINGCHANGE notification.
Thank you - the main window indeed receives a
WM_SETTINGCHANGE, both when installing and
deleting a printer.
Ah, that's good to know.
Post by Frank
Now another question -
is there a way to provoke a messsage box to
the user when he installs a printer? The
background is, I'd like to test whether the
message really does not arrive until the
user has "clicked away" all message boxes
so the printer is really completely installed.
I'd expect that any notification saying "there's a new printer
available" would only be sent once the printer could be used. Anything
else wouldn't make much sense. Is that what the notification is
telling you?

There will always be theoretical situations where you start to do
something only to find that when you try to do it, it fails. For
instance the user may add a printer, then immediately remove it. If
your code sees the "add" notification, but by the time you try to
access the printer, it's been removed, then you've got such a
situation - you have to handle that failure appropriately in your
code.
Post by Frank
I'm using mostly network printers, so
maybe I could provoke a small "problem"
with access rights or something?
All I can say is to ensure you thoroughly test all circumstances you
can think of that may be issues for whatever you're trying to achieve.

Dave

Continue reading on narkive:
Loading...