I know that this has been addressed many times on the boards but I have a new question that I have not been able to find an answer for anywhere.
I am creating a program that needs to send simple text, mostly C++ style string variables and some string literals, to the printer to create a hard copy. Using this simple example works:
The problem I am having is that it works only on my machine running windows 98 using a plain Dot Matrix Printer. It does NOT work on my machine running XP with an HP Deskjet. I though at first that it might have something to do with the deskjet printer verses the DMP but after googleing around it seems that windows XP does not allow applications to directly access a printer port, while 98 will. It seems that on XP you have to go through the printer driver.Code:#include <iostream> #include <fstream> using namespace std; int main() { ofstream printer("PRN"); if ( printer.fail() ) cout<<"\aPrinter NOT Open!!!"; else { cout<<"Printer Opened"<<endl; printer<<"This is a test string.\f"; printer.flush(); } printer.close(); cout<<"Test string sent to printer, hit <enter>"<<endl; cin.get(); return 0; }
My question is this, Is there a windows API or maybe a thrid party library function that I can download that will send text through the printer driver? Or maybe someone can explain how to program one myself or give a URL that explains it.
I really need this to work on both windows 98 and XP so the above program will not work
Thanks a Lot for any help, it is greatly appreciated.