This message is for informational purposes only. This message is advisory and does not have guaranteed delivery semantics. Applications should not assume that they will receive a WM_SPOOLERSTATUS message for every change in spooler status.
Note The WM_SPOOLERSTATUS message is not supported after Windows XP. To be notified of changes to the print queue status, use FindFirstPrinterChangeNotification and FindNextPrinterChangeNotification. The following code outlines how this might be done.
chgObject = FindFirstPrinterChangeNotification( hPrinter, PRINTER_CHANGE_JOB, 0, NULL);
WaitForSingleObject(chgObject, INFINTE);
fcnreturn = FindNextPrinterChangeNotification(chgObject, pdwChange, NULL, NULL);
if (fcnreturn) {
// check value of *pdwChange and deal with the indicated change
The WM_SPOOLERSTATUS message is sent from Print Manager whenever a job is added to or removed from the Print Manager queue.
A window receives this message through its WindowProc function.
转自msdn。
wm_spoolerstatus是一个可以全局接收的消息,就象插入USB设备产生的消息:WM_DEVICECHANGE。所以在你的窗口类WindowProc函数中可以截获。
又看了一下不用hook这么麻烦。
mfc程序使用:
LRESULT CALLBACK WindowProc(
HWND hwnd, // handle to window
UINT uMsg, // WM_SPOOLERSTATUS
WPARAM wParam, // job status
LPARAM lParam // number of jobs remaining
)
{
//The WM_SPOOLERSTATUS message is sent from Print Manager whenever a job is added to or removed from the Print Manager queue.
这个消息只是打印队列改变产生的,不知道对你会不会有什么启发。
if (message == wm_spoolerstatus)
{