tags:

views:

452

answers:

0

I'd like to require that a line printer be attached to the parallel port (and turned on!) before running my application. I had found code to check a particular line on the LPT for a particular level that was supposed to indicate that a printer was there and "ready", but I got inconsistent behavior with that, even between different printers of the same model.

Recently, I discovered that if the printer was hooked up but turned off, the write buffer for the port seemed to fill up, eventually causing write calls to block (apparently). This lead me to reason that maybe if I could check how full the write buffer is, I'd have a more robust printer-detection method -- print a "hello" message, wait a few milliseconds, then see if the message had left the port buffer or not. But I'm having trouble finding any ways to do this with kernel/platform SDK calls.

Can anybody help me out? Bonus points if it's straight managed code! Note: I don't want to have to install Windows drivers for this printer, so any use of Shell/Control Panel/WDM won't help me.

EDIT: To clarify, the "bonus points for managed code" meant that while the app is C#, if I have to do it in a C/C++ DLL then p/invoke that, that would be OK.

FOLLOW-UP: No answers? It's starting to look like Windows hates the LPT so much there's just no solution. That's OK -- it's not absolutely critical to make sure the printer is there, though it would have been nice. I'm going to close the question now, with a warning -- if you're trying to do the same thing, and you come across this question... don't expect your life to be very easy.