Just wonder if anyone faced this before. The code seems to work find at first. After I install a printer driver that uses LPT1, things get weird. I found that LPT1 is taking over by Spooler Manager, anything you you send to LPT1 will be intercept by Spooler Manager. It is ok for many applications, but not for my case. I actually use this to auto detect whether there is a good connection to the printer. I know the advice to use a parallel port driver, but somehow that is not allowable, and it's running on Win2K. Would appreciate if someone can show me a way to bypass Spooler Manager.
It's great to hear that there's a way you can print in MFC Dialog apps without using rocket science, but whenever I try it, my printer makes a chirp noise, like it's about to print, but it doesn't do anything.
This is really regressing 10 years in technology, but if
you know the printer understands HP PCL, then you can
send the old fashioned DOS-link escape sequences. This will let you change the font width and the line height.
We have the following net use command set up:
net use lpt1 \\server\printername /persistent:yes
Our application only allows us to select lpt1 as the output device, which works fine, but it always defaults to the #2 default paper tray. We would like the output to pull from the #3 tray.
Is there a switch that can be used with the line command above to send it to a different tray.
I created a VB program that sends raw data to the printspooler.
It works fine in both Win2k and Win98.
I translate that to c and it does not work in Win2k
Here is the VB code:
lReturn = OpenPrinter(List1.Text, lhPrinter, 0)
If lReturn = 0 Then
Set Fs = New FileSystemObject
MyDocInfo.pDocName = fname
MyDocInfo.pOutputFile = vbNullString
MyDocInfo.pDatatype = vbNullString
For x = 1 To Val(List2.Text)
Set FF = Fs.OpenTextFile(fname)
lDoc = StartDocPrinter(lhPrinter, 1, MyDocInfo)
Do While Not FF.AtEndOfStream
temp = FF.Read(BUFF_SIZE)
If Len(temp) > 0 Then
lReturn = WritePrinter(lhPrinter, ByVal temp, Len(temp), lpcWritten)
temp = ""
'lReturn = EndPagePrinter(lhPrinter)
lReturn = EndDocPrinter(lhPrinter)
lReturn = ClosePrinter(lhPrinter)
Here is the C code:
// OpenFileName section not shown
sprintf(msg,"Can't open %s",fname);
WritePrinter( hPrinter,temp,strlen(temp), &dwBytesWritten );
// lReturn = EndPagePrinter(hPrinter)
After extensive troubleshooting, I found everything is working except the actual printing under Win2k.Works fine under Win98.
What am I doing wrong?
I am generating spool file output & then give printing comand from shell, but this creates session which doesn't get killed and it shows "winoldap" in taskbar. If I give printing command five times, it create "Winoldap" in taskbar. How to solve this problem..
I used the code that was printed in the main article here, but it seems that Dick either forgot to mention or purposely left out the rest of the real world application for this code. I need this code so I can print data out to a reciept tape printer. He mentioned something about registry entries for opening the LPT1 port refered to in the code. If anyone knows how to do this, please email it to me, with a "real world application" that works. It would be greatly appreciated...THANK YOU!
I'm sending a series of text files (~400 byte CStrings) to LPT1. This chunk of code that works fine under Win98 without the do loop and works under NT with the do loop. Is there anyway to monitor the return values from the parallel port using Readfile? I really don't want to use the View class or write a device driver to do this.
for (int i = 0; i < p_qty; i++)
pars_buf += sn_head;
pars_buf += snNums.GetAt(i);
pars_buf += sn_tail;;
len = pars_buf.GetLength();
hFile = CreateFile("LPT1", GENERIC_WRITE, NULL, NULL, CREATE_ALWAYS FILE_ATTRIBUTE_NORMAL NULL);
while (hFile == INVALID_HANDLE_VALUE);