我正在尝试监视远程假脱机程序上的作业。我为此使用下面的代码。实际打印某些内容时,会调用 MyChangeCallback 并且我可以正常进行。但是,如果我在打印对话框上勾选“打印到文件”框,我的回调永远不会被调用。即使选择了“打印到文件”,任何想法如何使它工作?
// Callback definition
VOID MyChangeCallback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
{
DEBUG("Change notification received");
HANDLE hChange = *((HANDLE*)lpParameter));
// Call FindNextPrinterChangeNotification with hChange
...
}
int main() {
HANDLE hPrinter = 0;
OpenPrinter(L"\\MyPrintServer\\SharedPrinter", &hPrinter, NULL);
HANDLE hChange = FindFirstPrinterChangeNotification( hPrinter,
PRINTER_CHANGE_ALL,
0,
NULL);
HANDLE hNewWaitObj = 0;
RegisterWaitForSingleObject( &hNewWait,
hChange,
MyChangeCallback,
(PVOID)&hChange,
INFINITE,
WT_EXECUTEDEFAULT);
// Wait for events
Sleep(INFINITE);
}