call FindFirstPrinterChangeNotification() Get Error 997?
-
when I call FindFirstPrinterChangeNotification(), in release ,Get Fail,the Error code is 997,it mean the overload I/O is handing..... but In debug,it's ok! why? thanks
can you post part of the code that is making the API call?
-Prakash
-
can you post part of the code that is making the API call?
-Prakash
/* reinitialize the Termination Event so we can proceed */ ResetEvent(g_hTerminateEvent); hPrinterNotification = FindFirstPrinterChangeNotification( ThreadParam.hPrinter, /* The printer of interest */ PRINTER_CHANGE_DELETE_JOB, /* We need to know when a job is removed */ 0, /* reserved */ &NotificationOptions); /* The details of what notifications that are needed */ /* Check for an error */ if (hPrinterNotification == INVALID_HANDLE_VALUE) { LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL ); MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION ); LocalFree( lpMsgBuf ); return 0; } /* * Loop on the Notifications, a terminate event, or a refresh event */ /* setup for a WaitForMultipleObjects */ Handles[0] = hPrinterNotification; Handles[1] = g_hTerminateEvent; Handles[2] = g_hForceRefreshEvent; /* Initialize for our local data structure */ ZeroMemory(&Queue, sizeof(Queue)); Queue.Printer.hPrinter = ThreadParam.hPrinter; /* Initialize the display and our local copy of the printer queue data */ CPrinterJob::Refresh(ThreadParam.hWnd, &Queue); /* * Loop while we are stilling waiting on Notifications. */ while (hPrinterNotification != INVALID_HANDLE_VALUE) { /* wait for a printer notification, terminate event, or refresh event */ WaitForMultipleObjects(3, Handles, FALSE, INFINITE); /* check to see if the thread needs to quit. */ if (WaitForSingleObject(g_hTerminateEvent, 0) == WAIT_OBJECT_0) { /* This should be the only way out of the loop */ FindClosePrinterChangeNotification(hPrinterNotification); hPrinterNotification = INVALID_HANDLE_VALUE; } /* or check to see if the notification object for the printer queue is signaled */ else if (WaitForSingleObject(hPrinterNotification, 0) == WAIT_OBJECT_0) { /* get the changes and reset the notification */ if (!FindNextPrinterChangeNotification(hPrinterNotification, &WaitResult, /* for the PRINTER_CHANGE_DELETE_JOB notice */ &NotificationOptions, /* The notifications */ (void **)&pNotification)) /* address of pointer t