F
fasteddie203
Hi,
I hope this is appropriate for standard C++ group, I apologize if it is
not. I'm trying to print to LPT1 using ofstream which works fine as
long as the printer is connected - it doesn't need to be powered on.
However, if there is no printer at all, it seems the ofstream won't
detect the failure or close gracefully - but when the stream closes
(manually or when the stream's deconstructor is called) the application
hangs.
No exceptions get thrown either so I am not sure how to detect a
failure.
Here's the basic code snippets:
std:fstream print;
print.open("LPT1"); //no printer is hooked up.
//None of these return
if (!print)return 0;
if (print.fail()) return 0;
if (!print.isopen()) return 0;
print.close(); //Hangs
Any help/suggestions would be appreciated.
Thanks,
Michael
I hope this is appropriate for standard C++ group, I apologize if it is
not. I'm trying to print to LPT1 using ofstream which works fine as
long as the printer is connected - it doesn't need to be powered on.
However, if there is no printer at all, it seems the ofstream won't
detect the failure or close gracefully - but when the stream closes
(manually or when the stream's deconstructor is called) the application
hangs.
No exceptions get thrown either so I am not sure how to detect a
failure.
Here's the basic code snippets:
std:fstream print;
print.open("LPT1"); //no printer is hooked up.
//None of these return
if (!print)return 0;
if (print.fail()) return 0;
if (!print.isopen()) return 0;
print.close(); //Hangs
Any help/suggestions would be appreciated.
Thanks,
Michael