lebogang
January 11th, 2004, 03:44 AM
can any one help in using a win32 method FindNextPrinterChangeNotification()
the MSDN doc for it sais you must pass a LPVOID* to it to retrieve the print information. this info is stored in a system-allocated, read-only buffer.
But when the function returns this parameter is always null.
Can any one tell me what i could be doing wrong. here is the code i have written.
HANDLE CNHandle;
DWORD pdwChange = 0;//Pointer to conditions that changed
PRINTER_NOTIFY_OPTIONS pnoStruct; //Refresh options
LPPRINTER_NOTIFY_INFO pPrinterNotifyInfo = NULL;//to hold printer information
//getting the notification object handle
CNHandle = FindFirstPrinterChangeNotification(hPrinter, PRINTER_CHANGE_ADD_JOB, 0, NULL)) != INVALID_HANDLE_VALUE)
//waiting for a notification event
WaitForSingleObject(CNHandle , INFINITE);
//extracting print event information
if (FindNextPrinterChangeNotification(CNHandle, &pdwChange, &pnoStruct, (LPVOID*)&pPrinterNotifyInfo) == TRUE)
/*Always return NULL in pPrinterNotifyInfo even if the function does not fail*/
{
return 0;
}
**************************************************
*
thanks in advance
:blush:
the MSDN doc for it sais you must pass a LPVOID* to it to retrieve the print information. this info is stored in a system-allocated, read-only buffer.
But when the function returns this parameter is always null.
Can any one tell me what i could be doing wrong. here is the code i have written.
HANDLE CNHandle;
DWORD pdwChange = 0;//Pointer to conditions that changed
PRINTER_NOTIFY_OPTIONS pnoStruct; //Refresh options
LPPRINTER_NOTIFY_INFO pPrinterNotifyInfo = NULL;//to hold printer information
//getting the notification object handle
CNHandle = FindFirstPrinterChangeNotification(hPrinter, PRINTER_CHANGE_ADD_JOB, 0, NULL)) != INVALID_HANDLE_VALUE)
//waiting for a notification event
WaitForSingleObject(CNHandle , INFINITE);
//extracting print event information
if (FindNextPrinterChangeNotification(CNHandle, &pdwChange, &pnoStruct, (LPVOID*)&pPrinterNotifyInfo) == TRUE)
/*Always return NULL in pPrinterNotifyInfo even if the function does not fail*/
{
return 0;
}
**************************************************
*
thanks in advance
:blush: