本文介绍了在Windows Service中使用C ++获取默认打印机更改通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要点击默认打印机更改通知,这可能吗?

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

我的情况是,每当在窗口中更改默认打印机时,我都想执行命令。我的命令所做的是,它仅从注册表获取默认打印机信息,并将其保存在HKLM中。

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.

因此,我为此提供了服务。使用此服务,每当更改默认打印机时,如何点击通知。我正在使用C ++。

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++.

推荐答案

拦截消息WM_WININICHANGE,然后获得新的打印机:

Intercept message WM_WININICHANGE, then get the new printer:

PRINTDLGW *pd;
pd = (PRINTDLGW *)malloc(sizeof(PRINTDLGW));
pd->lStructSize = sizeof(PRINTDLGW);
pd->hDevMode = NULL;
pd->hDevNames = NULL;
pd->Flags = PD_RETURNDEFAULT;
PrintDlgW(pd);

这篇关于在Windows Service中使用C ++获取默认打印机更改通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 00:07