Averwind
Newbie

Offline
Beiträge: 1
|
 |
« am: 25.01.2008, 14:13:18 » |
|
I am trying to print line by line on a thermal printer using Windows generic printer drivers. The code I use to print a line is presented below. The code works OK. But the problem is the application freezes when there is a print operation. Is there something I am doing wrong? Should I use something else other than Winspool?
Procedure PrintLineToGeneric(Const line: string ); var BytesWritten: DWORD; DocInfo: TDocInfo1; Begin if WinSpool.OpenPrinter(PChar(printerName), hPrinter, nil) Then //raise exception.create('Printer not found'); Try DocInfo.pDocName := 'MyDocument'; DocInfo.pOutputFile := Nil; DocInfo.pDatatype := 'RAW'; If StartDocPrinter(hPrinter, 1, @DocInfo) = 0 Then Abort;
Try StartPagePrinter(hPrinter); If not StartPagePrinter(hPrinter) Then Abort; try If not WritePrinter(hPrinter, @line[1], Length(line), BytesWritten) Then Abort; Finally EndPagePrinter(hPrinter); End; Finally EndDocPrinter(hPrinter); End; Finally WinSpool.ClosePrinter(hPrinter); End; End;
|