Getting default printer change notification using

2019-08-04 06:41发布

问题:

I need to tap default printer change notification, is it possible?

My scenario is that I want to execute a command whenever default printer is changed in window. What my command does is, it just takes default printer information from registry and save it in HKLM.

So, I have a service for this. Using this service, how can i tap notifications whenever a default printer is changed. I am using C++.

回答1:

From a regular application, I would listen for a WM_SETTINGCHANGE message and then call GetDefaultPrinter to see if the default printer has actually changed.

I don't know if you can watch for that message from a service. The default printer can be a per-user setting, so your service would have to be running as that user rather than as Local System.