AddPrinterConnection() returns error 997 (Overlapped I/O operation is in progress)

A

Afterburn

Hi,

Has anyone ever experienced this error occuring when trying to call
AddPrinterConnection() from VC6. This is a microsoft defined method
call. I have been able to reproduce it on a windows200 professional
machine will latest service packs downloading the printer drivers from
a windows2003 server.

It seems to work on other configurations as I have been unable to
reproduce the problem occuring there.

According to the documentation for Overlapped I/O it basically means
that the operation has not completed yet but will complete later. If
this is the case how do you check that the request has completed and
shouldn't microsoft handle this and finish it's call once the driver
has completly downloaded.

Cheers.
 
W

William DePalo [MVP VC++]

Afterburn said:
Has anyone ever experienced this error occuring when trying to call
AddPrinterConnection() from VC6. This is a microsoft defined method
call. I have been able to reproduce it on a windows200 professional
machine will latest service packs downloading the printer drivers from
a windows2003 server.

At the risk of asking the obvious: Does the function return a true (i.e.
non-zero value) or FALSE (0)?

In case you don't know, calling GetLastError() is meaningful _only_ in the
case where a function fails - in this case where it returns zero - and then
only _immediately_ after the call to AddPrinterConnection(). The reason for
that is that the last error is a kind of thread-specific global variable
which is often, but not always, cleared on success.

Regards,
Will
 
A

Afterburn

Hi Will,

On the return type I checked this in the code for True or False and it
comes back false. When it comes back false I then check the error code
and it reports 997 (ERROR_IO_PENDING). This is the line of code I had
implemented.

if(!AddPrinterConnection(xxx)) {
DWORD lastError = GetLastError();
...
...
}

Do you think if I continue on and ignore this error it may work. Any
idea if there is a way to check if pending IO is currently in progress
and when it finishes.

Cheers,
A.
 
W

William DePalo [MVP VC++]

Afterburn said:
This is the line of code I had implemented.

if(!AddPrinterConnection(xxx)) {
DWORD lastError = GetLastError();
...
...

Assuming that the code is as wriiten above then that is the correct way to
do it.
Do you think if I continue on and ignore this error it may work.

I doubt it.
Any idea if there is a way to check if pending IO is currently
in progress and when it finishes.

Well, the initiator of the I/O can, but you can't because you don't have the
device handle or the "overlapped" structure or any other useful information
about the operation in progress.

I wish I had something good to tell you but I don't. In fact, there may not
even be I/O in progress. It is possible that the implementation has already
waited on the operation to complete but no subsequent operation has reset
the thread's last error code.

It might be a bug in a driver or something (wild a__ speculation on my
part). You might want to post again in a GDI group and hope for a more
definitive reply.

Regards,
Will
 
A

Afterburn

Hi Will,

Thanks for the info below. I think alright it's a bit of hit and miss
to try and pinpoint it down to why it could be happing. I did try
ignore the error and continue on anyway and as you say below this
didn't work, long shot I know :)

I'll post the message in one of the GDI groups and will post any
updates to this message if I get any additional info.

Thanks again,
A.B.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top