Click here to Skip to main content
15,880,469 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: FindNextPrinterChangeNotification - Invalid Handle Pin
Member 45238505-Apr-09 16:05
Member 45238505-Apr-09 16:05 
GeneralRe: FindNextPrinterChangeNotification - Invalid Handle Pin
pgibson0077006-Apr-09 0:55
pgibson0077006-Apr-09 0:55 
GeneralRe: FindNextPrinterChangeNotification - Invalid Handle Pin
Member 45238507-Apr-09 2:17
Member 45238507-Apr-09 2:17 
GeneralRe: FindNextPrinterChangeNotification - Invalid Handle Pin
honohsu14-Apr-09 15:24
honohsu14-Apr-09 15:24 
QuestionRe: FindNextPrinterChangeNotification - Invalid Handle Pin
David Crow31-May-06 5:25
David Crow31-May-06 5:25 
AnswerRe: FindNextPrinterChangeNotification - Invalid Handle Pin
pgibson00770031-May-06 9:08
pgibson00770031-May-06 9:08 
QuestionRe: FindNextPrinterChangeNotification - Invalid Handle Pin
David Crow31-May-06 9:18
David Crow31-May-06 9:18 
AnswerRe: FindNextPrinterChangeNotification - Invalid Handle Pin
pgibson00770031-May-06 10:54
pgibson00770031-May-06 10:54 
here is my code, I have taken out some debug strings, but the printername is valid as are the values of the handles returned. The code has been taken from the Microsoft Printmon example with just a few changes as I am using this in a class, hence the use of 'this'

// setup printer name

strcpy (pPrinterName, this->m_PrinterName);

// open Printer, if access denied return

ZeroMemory (&pd, sizeof (pd));
pd.DesiredAccess = PRINTER_ACCESS_USE;
if((nReturn = OpenPrinter (pPrinterName, &hPrinter, &pd)) == ERROR_ACCESS_DENIED) return FALSE;

// initialize local copy of the printer queue data

ZeroMemory (&Queue, sizeof(Queue));
Queue.Printer.hPrinter = hPrinter;
GetQueue (&Queue);

// prepare for notifications, we want when a job is added, check for an error

hPrinterNotification = FindFirstPrinterChangeNotification (hPrinter, PRINTER_CHANGE_JOB, 0, &NotificationOptions);

if (hPrinterNotification == INVALID_HANDLE_VALUE) return 0;

Queue.Printer.hPrinterNotification = hPrinterNotification;

// loop while we are stilling waiting on Notifications

while (Queue.Printer.hPrinterNotification != INVALID_HANDLE_VALUE)
{
if (WaitForSingleObject (Queue.Printer.hPrinterNotification, INFINITE) == WAIT_OBJECT_0)
{
// get the changes and reset the notification

if (!FindNextPrinterChangeNotification (Queue.Printer.hPrinterNotification, &dwWaitResult, &NotificationOptions, (void **)&pNotification))
{
ErrorBox(GetLastError(), "FindNextPrinterChangeNotification ...failed\r\n");
}


Note also that the Printmon example also fails at the FindNextPrinterChange call with an invalid handle when the printer is a network one, so the error is consistent.
Questionabout const Pin
FlyWithYou31-May-06 0:11
FlyWithYou31-May-06 0:11 
AnswerRe: about const Pin
toxcct31-May-06 0:21
toxcct31-May-06 0:21 
AnswerRe: about const Pin
NiceNaidu31-May-06 0:23
NiceNaidu31-May-06 0:23 
AnswerRe: about const Pin
Sarath C31-May-06 0:35
Sarath C31-May-06 0:35 
GeneralRe: about const Pin
Emilio Garavaglia31-May-06 2:29
Emilio Garavaglia31-May-06 2:29 
AnswerRe: about const Pin
Michael Dunn31-May-06 2:03
sitebuilderMichael Dunn31-May-06 2:03 
AnswerRe: about const Pin
David Crow31-May-06 5:32
David Crow31-May-06 5:32 
QuestionEthernet Permanent MAc Address Pin
PierMario31-May-06 0:02
PierMario31-May-06 0:02 
AnswerRe: Ethernet Permanent MAc Address Pin
Naveen31-May-06 1:24
Naveen31-May-06 1:24 
QuestionProjective transformation Algorithm required Pin
Arun Tayal30-May-06 23:57
Arun Tayal30-May-06 23:57 
QuestionWaitForDebugEvent Pin
HakunaMatada30-May-06 23:50
HakunaMatada30-May-06 23:50 
AnswerRe: WaitForDebugEvent Pin
Sarath C31-May-06 0:06
Sarath C31-May-06 0:06 
AnswerRe: WaitForDebugEvent Pin
Sarath C31-May-06 0:09
Sarath C31-May-06 0:09 
AnswerRe: WaitForDebugEvent Pin
NiceNaidu31-May-06 0:10
NiceNaidu31-May-06 0:10 
QuestionWhy this is not failing in VC6 Pin
NiceNaidu30-May-06 23:29
NiceNaidu30-May-06 23:29 
AnswerRe: Why this is not failing in VC6 Pin
toxcct30-May-06 23:36
toxcct30-May-06 23:36 
GeneralRe: Why this is not failing in VC6 Pin
NiceNaidu30-May-06 23:48
NiceNaidu30-May-06 23:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.