票据打印机精确控制问题(200分)

  • 主题发起人 主题发起人 dapao
  • 开始时间 开始时间
D

dapao

Unregistered / Unconfirmed
GUEST, unregistred user!
大家好,我现在遇到了一个比较难的问题:我用的是票据打印机,我为了斯票据方便,我设置了一下,打印完以后让它多出了一点纸。可是下次再打印时还得重新按退纸键和联机键,非常的麻烦。我想下次点打印按钮时,让它自动退纸到打印行,怎么用程序来实现呢?
 
[:(]大家帮帮忙啊,分不够再加!
 
在线等待
 
你要Dos打印还是Windows打印,并口,还是串口? &nbsp; <br>&nbsp; 都有。 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; {*******************************************************} &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Musicwind &nbsp; Delphi &nbsp; Development &nbsp; Package &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DosPrinter &nbsp; Unit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Copyright &nbsp; ( &nbsp; c &nbsp; ) &nbsp; 2000,2005 &nbsp; Musicwind &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; Build &nbsp; with &nbsp; Delphi5, &nbsp; Musicwind &nbsp; &nbsp; &nbsp; &nbsp; [2000-03-??] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; TDosPrinter &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; {*******************************************************} &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; unit &nbsp; DosPrinter; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; // &nbsp; &nbsp; Note: &nbsp; Only &nbsp; Be &nbsp; Ok &nbsp; in &nbsp; Win98, &nbsp; and &nbsp; the &nbsp; printer &nbsp; must &nbsp; be &nbsp; in &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; lpt1, &nbsp; lpt2 &nbsp; or &nbsp; lpt3; &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And &nbsp; Be &nbsp; Sure &nbsp; your &nbsp; Windows &nbsp; does &nbsp; not &nbsp; install &nbsp; the &nbsp; printer &nbsp; <br>&nbsp; // &nbsp; <br>&nbsp; // &nbsp; &nbsp; User &nbsp; Guide: &nbsp; &nbsp; &nbsp; Just &nbsp; add &nbsp; this &nbsp; unit &nbsp; into &nbsp; the &nbsp; "uses" &nbsp; clause, &nbsp; then &nbsp; you &nbsp; may &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; LPT1.Write, &nbsp; LPT1.WriteLn, &nbsp; LTP1.WriteFmt &nbsp; directly &nbsp; to &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; make &nbsp; output &nbsp; on &nbsp; the &nbsp; printer. &nbsp; (LPT2 &nbsp; is &nbsp; also &nbsp; supported). &nbsp; <br>&nbsp; // &nbsp; <br>&nbsp; // &nbsp; &nbsp; Limitation: &nbsp; &nbsp; &nbsp; This &nbsp; unit &nbsp; does &nbsp; not &nbsp; have &nbsp; error &nbsp; checking &nbsp; capabilities. &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; // &nbsp; &nbsp; New &nbsp; added &nbsp; Guide: &nbsp; <br>&nbsp; // &nbsp; &nbsp; TDosPrinter; &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Can &nbsp; Check &nbsp; whether &nbsp; the &nbsp; printer &nbsp; is &nbsp; empty &nbsp; of &nbsp; paper, &nbsp; or &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; printer &nbsp; does &nbsp; not &nbsp; linked, &nbsp; or &nbsp; other &nbsp; errors. &nbsp; <br>&nbsp; // &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; interface &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; uses &nbsp; Classes, &nbsp; SysUtils, &nbsp; Windows, &nbsp; MusicSys; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; type &nbsp; <br>&nbsp; &nbsp; &nbsp; // &nbsp; 并口号 &nbsp; <br>&nbsp; &nbsp; &nbsp; TDosLptPort &nbsp; = &nbsp; ( &nbsp; dpLpt1, &nbsp; dpLpt2, &nbsp; dpLpt3 &nbsp; ); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; // &nbsp; 错误类别, &nbsp; ( &nbsp; 未联机, &nbsp; 缺纸, &nbsp; 超时 &nbsp; ) &nbsp;   &nbsp; <br>&nbsp; &nbsp; &nbsp; TErrType &nbsp; = &nbsp; ( &nbsp; etLinkLost, &nbsp; etLackPaper, &nbsp; etTimeout &nbsp; ); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; // &nbsp; 打印错误事件 &nbsp; <br>&nbsp; &nbsp; &nbsp; TErrMsgEvent &nbsp; = &nbsp; procedure(Sender: &nbsp; TObject; &nbsp; ErrType: &nbsp; TErrType; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var &nbsp; Retry: &nbsp; Boolean &nbsp; ) &nbsp; of &nbsp; object; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; TDosPrinter &nbsp; = &nbsp; class &nbsp; <br>&nbsp; &nbsp; &nbsp; private &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FLptPort: &nbsp; TDosLptPort; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FOnErr: &nbsp; TErrMsgEvent; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FblActive: &nbsp; Boolean; &nbsp; <br>&nbsp; &nbsp; &nbsp; protected &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; public &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Constructor &nbsp; Create; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; BeginDoc; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; EndDoc; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; DoDoubleWidth( &nbsp; bl: &nbsp; Boolean &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; DoDoubleHeight( &nbsp; bl: &nbsp; Boolean &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; DoBold( &nbsp; bl: &nbsp; Boolean &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; ChineseMode; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; DoExpress( &nbsp; bl: &nbsp; Boolean &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; CR; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; Writeln( &nbsp; sLine: &nbsp; string &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; Write( &nbsp; sLine: &nbsp; string &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function &nbsp; WriteChar( &nbsp; Achar: &nbsp; char &nbsp; ): &nbsp; Boolean; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; MovePaper( &nbsp; iSize: &nbsp; integer &nbsp; ); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; Active: &nbsp; Boolean &nbsp; read &nbsp; FblActive; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; LptPort: &nbsp; TDosLptPort &nbsp; read &nbsp; FLptPort &nbsp; write &nbsp; FLptPort; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; OnErr: &nbsp; TErrMsgEvent &nbsp; read &nbsp; FOnErr &nbsp; write &nbsp; FOnErr; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; DosLpt1: &nbsp; TDosPrinter; &nbsp; <br>&nbsp; function &nbsp; DosLpt2: &nbsp; TDosPrinter; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; implementation &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; var &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; _DosLpt1: &nbsp; TDosPrinter &nbsp; = &nbsp; nil; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; _DosLpt2: &nbsp; TDosPrinter &nbsp; = &nbsp; nil; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; DosLpt1: &nbsp; TDosPrinter; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; not &nbsp; Assigned( &nbsp; _DosLpt1 &nbsp; ) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _DosLpt1 &nbsp; := &nbsp; TDosPrinter.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _DosLpt1.LptPort &nbsp; := &nbsp; dpLpt1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; result &nbsp; := &nbsp; _DosLpt1; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; DosLpt2: &nbsp; TDosPrinter; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; not &nbsp; Assigned( &nbsp; _DosLpt2 &nbsp; ) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _DosLpt2 &nbsp; := &nbsp; TDosPrinter.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _DosLpt2.LptPort &nbsp; := &nbsp; dpLpt2; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; result &nbsp; := &nbsp; _DosLpt2; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; { &nbsp; TDosPrinter &nbsp; } &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.BeginDoc; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; Do &nbsp; nothing &nbsp; ... &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.ChineseMode; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #28 &nbsp; + &nbsp; '&amp;' &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.CR; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #13 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; constructor &nbsp; TDosPrinter.Create; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FLptPort &nbsp; := &nbsp; dpLpt1; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FblActive &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.DoBold(bl: &nbsp; Boolean); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bl &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'E' &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'F' &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.DoDoubleHeight(bl: &nbsp; Boolean); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bl &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'w' &nbsp; + &nbsp; #1 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'w' &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.DoDoubleWidth(bl: &nbsp; Boolean); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bl &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'W' &nbsp; + &nbsp; #1 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'W' &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.DoExpress(bl: &nbsp; Boolean); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bl &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #28 &nbsp; + &nbsp; 'x' &nbsp; + &nbsp; #1 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #28 &nbsp; + &nbsp; 'x' &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.EndDoc; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; Do &nbsp; nothing &nbsp; ... &nbsp; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.MovePaper(iSize: &nbsp; integer); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'J' &nbsp; + &nbsp; char( &nbsp; iSize &nbsp; mod &nbsp; 255 &nbsp; ) &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.Write(sLine: &nbsp; string); &nbsp; <br>&nbsp; var &nbsp; <br>&nbsp; &nbsp; &nbsp; index: &nbsp; longint; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; for &nbsp; Index &nbsp; := &nbsp; 1 &nbsp; to &nbsp; length( &nbsp; sLine &nbsp; ) &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; not &nbsp; WriteChar( &nbsp; sLine[Index] &nbsp; &nbsp; ) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Break; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; TDosPrinter.WriteChar( &nbsp; AChar: &nbsp; char): &nbsp; Boolean; &nbsp; <br>&nbsp; var &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; byteChar, &nbsp; byteStatus: &nbsp; Byte; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; wordLpt: &nbsp; Word; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; bPaperOut, &nbsp; bSelected, &nbsp; bIOError, &nbsp; bTimeOut, &nbsp; bOK: &nbsp; Boolean; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; below &nbsp; is &nbsp; new &nbsp; added &nbsp; by &nbsp; Musicwind, &nbsp; 2001-02-08 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FErrType: &nbsp; TErrType; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Retry: &nbsp; Boolean; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; dwTimeOut: &nbsp; DWORD; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; result &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; not &nbsp; mscIsWin98 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FblActive &nbsp; := &nbsp; result; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; byteChar &nbsp; := &nbsp; byte( &nbsp; AChar &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FLptPort &nbsp; = &nbsp; dpLpt1 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wordLpt &nbsp; := &nbsp; 0 &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FLptPort &nbsp; = &nbsp; dpLpt2 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wordLpt &nbsp; := &nbsp; 1 &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FLptPort &nbsp; = &nbsp; dpLpt3 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wordLpt &nbsp; := &nbsp; 2 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; wordLpt &nbsp; := &nbsp; 0; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; repeat &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; retry &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; byteStatus &nbsp; := &nbsp; $40; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; while &nbsp; (( &nbsp; byteStatus &nbsp; and &nbsp; $80 &nbsp; ) &nbsp; = &nbsp; 0 &nbsp; ) &nbsp; and &nbsp; (( &nbsp; byteStatus &nbsp; and &nbsp; $40 &nbsp; ) &nbsp; &lt;&gt; &nbsp; 0 &nbsp; ) &nbsp; do &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; asm &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; AH, &nbsp; 0 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; DX, &nbsp; wordLpt &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; AL, &nbsp; byteChar &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; INT &nbsp; 17H &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; MOV &nbsp; byteStatus, &nbsp; AH &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bTimeOut &nbsp; := &nbsp; ( &nbsp; byteStatus &nbsp; and &nbsp; $01 &nbsp; ) &nbsp; &lt;&gt; &nbsp; 0; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bIOError &nbsp; := &nbsp; ( &nbsp; byteStatus &nbsp; and &nbsp; $08 &nbsp; ) &nbsp; &lt;&gt; &nbsp; 0; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bSelected &nbsp; := &nbsp; ( &nbsp; byteStatus &nbsp; and &nbsp; $10 &nbsp; ) &nbsp; &lt;&gt; &nbsp; 0; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; bPaperOut &nbsp; := &nbsp; ( &nbsp; byteStatus &nbsp; and &nbsp; $20 &nbsp; ) &nbsp; &lt;&gt; &nbsp; 0; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bTimeOut &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FErrType &nbsp; := &nbsp; etTimeOut &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bSelected &nbsp; and &nbsp; bPaperOut &nbsp; and &nbsp; bIOError &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FErrType &nbsp; := &nbsp; etLackPaper &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bSelected &nbsp; and &nbsp; bPaperOut &nbsp; or &nbsp; bIOError &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FErrType &nbsp; := &nbsp; etLinkLost &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; Print &nbsp; content &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; not &nbsp; result &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Retry &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; Assigned( &nbsp; FOnErr &nbsp; ) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Retry &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FOnErr( &nbsp; Self, &nbsp; FErrType, &nbsp; Retry &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; until &nbsp; result &nbsp; or &nbsp; not &nbsp; Retry; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FblActive &nbsp; := &nbsp; result; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; not &nbsp; FblActive &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; raise &nbsp; Exception.Create( &nbsp; '打印出错!' &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TDosPrinter.Writeln(sLine: &nbsp; string); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; sLine &nbsp; + &nbsp; #13#10 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; initialization &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; finalization &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; end. &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; {*******************************************************} &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Musicwind &nbsp; Delphi &nbsp; Development &nbsp; Package &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Lpt &nbsp; Unit &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Copyright &nbsp; ( &nbsp; c &nbsp; ) &nbsp; 2000,2005 &nbsp; Musicwind &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; History: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; Build &nbsp; with &nbsp; Delphi5, &nbsp; Musicwind &nbsp; &nbsp; &nbsp; &nbsp; [2000-12-18] &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; TLpt &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; TLptStream &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; TEpson300K &nbsp; <br>&nbsp; { &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; } &nbsp; <br>&nbsp; {*******************************************************} &nbsp; <br>&nbsp; unit &nbsp; LPT; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; // &nbsp; &nbsp; Note: &nbsp; Only &nbsp; Be &nbsp; Ok &nbsp; in &nbsp; WinNt &nbsp; or &nbsp; later &nbsp; OS &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; And &nbsp; Be &nbsp; Sure &nbsp; your &nbsp; Windows &nbsp; does &nbsp; not &nbsp; install &nbsp; the &nbsp; printer &nbsp; <br>&nbsp; // &nbsp; <br>&nbsp; // &nbsp; &nbsp; User &nbsp; Guide: &nbsp; &nbsp; &nbsp; Just &nbsp; add &nbsp; this &nbsp; unit &nbsp; into &nbsp; the &nbsp; "uses" &nbsp; clause, &nbsp; then &nbsp; you &nbsp; may &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; call &nbsp; LPT1.Write, &nbsp; LPT1.WriteLn, &nbsp; LTP1.WriteFmt &nbsp; directly &nbsp; to &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; make &nbsp; output &nbsp; on &nbsp; the &nbsp; printer. &nbsp; (LPT2 &nbsp; is &nbsp; also &nbsp; supported). &nbsp; <br>&nbsp; // &nbsp; <br>&nbsp; // &nbsp; &nbsp; Limitation: &nbsp; &nbsp; &nbsp; This &nbsp; unit &nbsp; does &nbsp; not &nbsp; have &nbsp; error &nbsp; checking &nbsp; capabilities. &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; // &nbsp; &nbsp; New &nbsp; added &nbsp; Guide: &nbsp; <br>&nbsp; // &nbsp; &nbsp; TEpson300K; &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; added &nbsp; for &nbsp; Epson &nbsp; 300K &nbsp; , &nbsp; by &nbsp; Musicwind, &nbsp; at &nbsp; 2000-12-18 &nbsp; <br>&nbsp; // &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; interface &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; uses &nbsp; Classes, &nbsp; SysUtils, &nbsp; Windows, &nbsp; SyncObjs; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; type &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; TLPT &nbsp; = &nbsp; class &nbsp; <br>&nbsp; &nbsp; &nbsp; protected &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FDeviceName: &nbsp; string; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FHandle: &nbsp; THandle; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FEvent: &nbsp; TSimpleEvent; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FOverlap: &nbsp; TOverlapped; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; SetActive(Value: &nbsp; Boolean); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; SetDeviceName(AName: &nbsp; string); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function &nbsp; &nbsp; GetActive: &nbsp; Boolean; &nbsp; <br>&nbsp; &nbsp; &nbsp; public &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; constructor &nbsp; Create; &nbsp; virtual; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; destructor &nbsp; Destroy; &nbsp; override; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; Open; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; Close; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; WriteBuf(const &nbsp; Buf: &nbsp; PChar; &nbsp; Len: &nbsp; Integer); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; Write(const &nbsp; AString: &nbsp; string); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; WriteLn(const &nbsp; AString: &nbsp; string); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; WriteFmt(const &nbsp; FmtStr: &nbsp; string; &nbsp; Args: &nbsp; array &nbsp; of &nbsp; const); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; Active: &nbsp; Boolean &nbsp; read &nbsp; GetActive &nbsp; write &nbsp; SetActive; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; Handle: &nbsp; THandle &nbsp; read &nbsp; FHandle; &nbsp; <br>&nbsp; &nbsp; &nbsp; published &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; DeviceName: &nbsp; string &nbsp; read &nbsp; FDeviceName &nbsp; write &nbsp; SetDeviceName; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; TLPTStream &nbsp; = &nbsp; class(TStream) &nbsp; <br>&nbsp; &nbsp; &nbsp; public &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function &nbsp; Read(var &nbsp; Buffer; &nbsp; Count: &nbsp; Longint): &nbsp; Longint; &nbsp; override; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function &nbsp; Write(const &nbsp; Buffer; &nbsp; Count: &nbsp; Longint): &nbsp; Longint; &nbsp; override; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function &nbsp; Seek(Offset: &nbsp; Longint; &nbsp; Origin: &nbsp; Word): &nbsp; Longint; &nbsp; override; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; WriteLn(const &nbsp; S: &nbsp; string); &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; TEpson300K &nbsp; = &nbsp; class &nbsp; ( &nbsp; TLpt &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; private &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FiPageHeight: &nbsp; integer; &nbsp; // &nbsp; 一页的高度( &nbsp; 单位:英寸 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FblChinese: &nbsp; Boolean; &nbsp; &nbsp; &nbsp; // &nbsp; 汉字打印模式 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FblExpress: &nbsp; Boolean; &nbsp; &nbsp; &nbsp; // &nbsp; 高速打印模式 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; SetFiPageHeight(const &nbsp; Value: &nbsp; integer); &nbsp; // &nbsp; 页长度, &nbsp; 单位( &nbsp; 英寸 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; public &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; constructor &nbsp; Create; &nbsp; override; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; BeginDoc; &nbsp; &nbsp; // &nbsp; 开始一个文档 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; EndDoc; &nbsp; &nbsp; &nbsp; &nbsp; // &nbsp; 结束.... &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; BeginPage; &nbsp; // &nbsp; 开始页 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; EndPage; &nbsp; &nbsp; &nbsp; // &nbsp; 结束页 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; BeginBold; &nbsp; // &nbsp; 开始粗体 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; EndBold; &nbsp; &nbsp; &nbsp; // &nbsp; 结束粗体 &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; MovePaper( &nbsp; iHeight: &nbsp; integer &nbsp; ); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; DoubleHeight(bl: &nbsp; Boolean); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; procedure &nbsp; DoubleWidth(bl: &nbsp; Boolean); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; PageHeight: &nbsp; integer &nbsp; read &nbsp; FiPageHeight &nbsp; write &nbsp; SetFiPageHeight; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; ChineseMode: &nbsp; Boolean &nbsp; read &nbsp; FblChinese &nbsp; write &nbsp; FblChinese; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; property &nbsp; ExpressMode: &nbsp; Boolean &nbsp; read &nbsp; FblExpress &nbsp; write &nbsp; FblExpress; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; LPT1: &nbsp; TLPT; &nbsp; <br>&nbsp; function &nbsp; LPT2: &nbsp; TLPT; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; Epson300k1: &nbsp; TEpson300k; &nbsp; <br>&nbsp; function &nbsp; Epson300k2: &nbsp; TEpson300k; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; implementation &nbsp; &nbsp; // &nbsp; =========================================================== &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; var &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; _LPT1: &nbsp; TLPT &nbsp; = &nbsp; nil; &nbsp; <br>&nbsp; &nbsp; &nbsp; _LPT2: &nbsp; TLPT &nbsp; = &nbsp; nil; &nbsp; <br>&nbsp; &nbsp; &nbsp; _Epson300k1: &nbsp; TEpson300k &nbsp; = &nbsp; nil; &nbsp; <br>&nbsp; &nbsp; &nbsp; _Epson300k2: &nbsp; TEpson300k &nbsp; = &nbsp; nil; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; { &nbsp; TLPT &nbsp; } &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; constructor &nbsp; TLPT.Create; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; FDeviceName &nbsp; := &nbsp; 'LPT1'; &nbsp; <br>&nbsp; &nbsp; &nbsp; FEvent &nbsp; := &nbsp; TSimpleEvent.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; FOverlap.hEvent &nbsp; := &nbsp; FEvent.Handle; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; destructor &nbsp; TLPT.Destroy; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; &nbsp; &nbsp; inherited; &nbsp; <br>&nbsp; end; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.SetActive(Value: &nbsp; Boolean); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; Value &nbsp; = &nbsp; Active &nbsp; then &nbsp; exit; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; Value &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FHandle &nbsp; := &nbsp; CreateFile(PChar(FDeviceName), &nbsp; GENERIC_WRITE, &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FILE_SHARE_READ &nbsp; or &nbsp; FILE_SHARE_WRITE, &nbsp; nil, &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; OPEN_EXISTING, &nbsp; FILE_FLAG_NO_BUFFERING &nbsp; or &nbsp; FILE_FLAG_OVERLAPPED, &nbsp; 0); &nbsp; <br>&nbsp; &nbsp; &nbsp; end &nbsp; <br>&nbsp; &nbsp; &nbsp; else &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; CloseHandle(FHandle); &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FHandle &nbsp; := &nbsp; INVALID_HANDLE_VALUE; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.SetDeviceName(AName: &nbsp; string); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; &nbsp; &nbsp; FDeviceName &nbsp; := &nbsp; AName; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; &nbsp; TLPT.GetActive: &nbsp; Boolean; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Result &nbsp; := &nbsp; FHandle &nbsp; &lt;&gt; &nbsp; INVALID_HANDLE_VALUE; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.Open; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.Close; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.WriteBuf(const &nbsp; Buf: &nbsp; PChar; &nbsp; Len: &nbsp; Integer); &nbsp; <br>&nbsp; var &nbsp; <br>&nbsp; &nbsp; &nbsp; Num: &nbsp; Integer; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; Active &nbsp; = &nbsp; False &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; Active &nbsp; and &nbsp; (Len &nbsp; &gt; &nbsp; 0) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; WriteFile(FHandle, &nbsp; Buf^, &nbsp; Cardinal( &nbsp; Len &nbsp; ), &nbsp; Cardinal( &nbsp; Num &nbsp; ), &nbsp; @FOverlap); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.Write(const &nbsp; AString: &nbsp; string); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; WriteBuf(PChar(AString), &nbsp; Length(AString)); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.WriteLn(const &nbsp; AString: &nbsp; string); &nbsp; <br>&nbsp; const &nbsp; <br>&nbsp; &nbsp; &nbsp; CRLF: &nbsp; array[0..1] &nbsp; of &nbsp; Char &nbsp; = &nbsp; (#13, &nbsp; #10); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; WriteBuf(PChar(AString), &nbsp; Length(AString)); &nbsp; <br>&nbsp; &nbsp; &nbsp; WriteBuf(CRLF, &nbsp; 2); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPT.WriteFmt(const &nbsp; FmtStr: &nbsp; string; &nbsp; Args: &nbsp; array &nbsp; of &nbsp; const); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Write(Format(FmtStr, &nbsp; Args)); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; TLPTStream.Read(var &nbsp; Buffer; &nbsp; Count: &nbsp; Longint): &nbsp; Longint; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Result &nbsp; := &nbsp; 0; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; TLPTStream.Write(const &nbsp; Buffer; &nbsp; Count: &nbsp; Longint): &nbsp; Longint; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Result &nbsp; := &nbsp; Count; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; Count &nbsp; &gt; &nbsp; 0 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; LPT1.WriteBuf(PChar(@Buffer), &nbsp; Count); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; TLPTStream.Seek(Offset: &nbsp; Longint; &nbsp; Origin: &nbsp; Word): &nbsp; Longint; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; Result &nbsp; := &nbsp; 0; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TLPTStream.WriteLn(const &nbsp; S: &nbsp; string); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; LPT1.WriteLn(S); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; // &nbsp; &nbsp; ========================================================================== &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; LPT1: &nbsp; TLPT; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; _LPT1 &nbsp; = &nbsp; nil &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _LPT1 &nbsp; := &nbsp; TLPT.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _LPT1.DeviceName &nbsp; := &nbsp; 'LPT1'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _LPT1.Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; Result &nbsp; := &nbsp; _LPT1; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; Epson300k1: &nbsp; TEpson300k; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; _Epson300k1 &nbsp; = &nbsp; nil &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Epson300k1 &nbsp; := &nbsp; TEpson300k.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Epson300k1.DeviceName &nbsp; := &nbsp; 'LPT1'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Epson300k1.Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; result &nbsp; := &nbsp; _Epson300k1; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; Epson300k2: &nbsp; TEpson300k; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; _Epson300k2 &nbsp; = &nbsp; nil &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Epson300k2 &nbsp; := &nbsp; TEpson300k.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Epson300k2.DeviceName &nbsp; := &nbsp; 'LPT2'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _Epson300k2.Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; result &nbsp; := &nbsp; _Epson300k2; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; function &nbsp; LPT2: &nbsp; TLPT; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; _LPT2 &nbsp; = &nbsp; nil &nbsp; then &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _LPT2 &nbsp; := &nbsp; TLPT.Create; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _LPT2.DeviceName &nbsp; := &nbsp; 'LPT2'; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; _LPT2.Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; &nbsp; &nbsp; Result &nbsp; := &nbsp; _LPT2; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; // &nbsp; &nbsp; ========================================================================== &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; { &nbsp; TEpson300K &nbsp; } &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.BeginBold; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'E' &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.DoubleWidth( &nbsp; bl: &nbsp; Boolean &nbsp; ); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bl &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'W' &nbsp; + &nbsp; #1 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'W' &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.DoubleHeight( &nbsp; bl: &nbsp; Boolean &nbsp; ); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; bl &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'w' &nbsp; + &nbsp; #1 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'w' &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.BeginDoc; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FblChinese &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #28 &nbsp; + &nbsp; '&amp;' &nbsp; ) &nbsp; ; &nbsp; // &nbsp; 设定汉字打印模式 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FblExpress &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #28 &nbsp; + &nbsp; 'x' &nbsp; + &nbsp; #1 &nbsp; ) &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; else &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #28 &nbsp; + &nbsp; 'x' &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.BeginPage; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; ( &nbsp; FiPageHeight &nbsp; &gt;= &nbsp; 1 &nbsp; ) &nbsp; and &nbsp; ( &nbsp; FiPageHeight &nbsp; &lt;= &nbsp; 22 &nbsp; ) &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'C' &nbsp; + &nbsp; #0 &nbsp; + &nbsp; Char( &nbsp; FiPageHeight &nbsp; ) &nbsp; ) &nbsp; ; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; '$' &nbsp; + &nbsp; #0 &nbsp; + &nbsp; #0 &nbsp; ); &nbsp; // &nbsp; 设定绝对位置为 &nbsp; y=0, &nbsp; x=0 &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; end; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; constructor &nbsp; TEpson300K.Create; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; inherited; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FiPageHeight &nbsp; := &nbsp; 0; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FblChinese &nbsp; := &nbsp; True; &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FblExpress &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.EndBold; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #27 &nbsp; + &nbsp; 'F' &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.EndDoc; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Active &nbsp; := &nbsp; False; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.EndPage; &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; if &nbsp; FiPageHeight &nbsp; &lt;&gt; &nbsp; 0 &nbsp; then &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Write( &nbsp; #12 &nbsp; ); &nbsp; &nbsp; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.MovePaper(iHeight: &nbsp; integer); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; Writeln( &nbsp; #27 &nbsp; + &nbsp; 'J' &nbsp; + &nbsp; char( &nbsp; iHeight &nbsp; mod &nbsp; 255 &nbsp; ) &nbsp; ); &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; procedure &nbsp; TEpson300K.SetFiPageHeight(const &nbsp; Value: &nbsp; integer); &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; FiPageHeight &nbsp; := &nbsp; Value &nbsp; mod &nbsp; 22; &nbsp; <br>&nbsp; end; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; initialization &nbsp; <br>&nbsp; finalization &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; _LPT1 &nbsp; &lt;&gt; &nbsp; nil &nbsp; then &nbsp; _LPT1.Free; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; _LPT2 &nbsp; &lt;&gt; &nbsp; nil &nbsp; then &nbsp; _LPT2.Free; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; _Epson300k1 &nbsp; &lt;&gt; &nbsp; nil &nbsp; then &nbsp; _Epson300k1.Free; &nbsp; <br>&nbsp; &nbsp; &nbsp; if &nbsp; _Epson300k2 &nbsp; &lt;&gt; &nbsp; nil &nbsp; then &nbsp; _Epson300k2.Free; &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; end.
 
代码是从其他地方贴来的,你研究下,应该对解决你的问题有帮助。
 
我研究一下,先谢谢了。
 
用代码的方式也太累了。
 
打印机上应该有这种按钮可以设置。
 
有没有针对所有打印机的程序阿
 
不同的打印机的控制符是不同的,可以参考使用手册。<br>举例:<br>这些票据打印机手册上都会有的, &nbsp; <br>&nbsp; 这是票据打印一段代码(Epson &nbsp; LQ300K),仅供参考: &nbsp; <br>&nbsp; procedure &nbsp; PrintTicket(AStation,Achannel,Auserid,ATicketNo, &nbsp; <br>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AMoney,APntdate,APnttime:string);stdcall; &nbsp; <br>&nbsp; var &nbsp; <br>&nbsp; &nbsp; &nbsp; F:TextFile; &nbsp; <br>&nbsp; &nbsp; &nbsp; ... &nbsp; <br>&nbsp; begin &nbsp; <br>&nbsp; &nbsp; &nbsp; .... &nbsp; <br>&nbsp; &nbsp; &nbsp; Assignfile(f,'LPT1'); &nbsp; &nbsp; &nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; rewrite(f); &nbsp; <br>&nbsp; &nbsp; &nbsp; {初始化打印机} &nbsp; <br>&nbsp; &nbsp; &nbsp; Write(f,chr(27)+'@'); &nbsp; &nbsp; //Chr(27)+'@' &nbsp; 即ESC &nbsp; @ &nbsp; 指令 &nbsp; <br>&nbsp; &nbsp; &nbsp; {设置汉字显示方式} &nbsp; <br>&nbsp; &nbsp; &nbsp; write(f,chr(28)+chr(ord('&amp;'))); &nbsp; &nbsp; //Chr(28) &nbsp; 即 &nbsp; FS &nbsp; <br>&nbsp; &nbsp; &nbsp; {设定打印相对水平位置} &nbsp; <br>&nbsp; &nbsp; &nbsp; Write(f,chr(27)+chr(ord('/'))+chr($CF)+chr($00)); &nbsp; <br>&nbsp; &nbsp; &nbsp; //设置高速打印 &nbsp; <br>&nbsp; &nbsp; &nbsp; //write(f,chr(28)+chr(ord('x'))+chr($01)); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f,PrintChannel+space(16)+Auserid+space(12)+carType); &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f); &nbsp; <br>&nbsp; &nbsp; &nbsp; write(f,chr(27)+chr(ord('/'))+chr($CF)+chr($00)); &nbsp; <br>&nbsp; &nbsp; &nbsp; Write(f, &nbsp; AMoney); &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f,Space(26)+PrntTicketno); &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f); &nbsp; <br>&nbsp; &nbsp; &nbsp; write(f,chr(27)+chr(ord('/'))+chr($CF)+chr($00)); &nbsp; <br>&nbsp; &nbsp; &nbsp; //Writeln(f); &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f,Apntdate+Space(12)+ApntTime); &nbsp; <br>&nbsp; &nbsp; &nbsp; //顺时针走纸控制 &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f,chr(27)+chr(ord('J'))+chr($FF)); &nbsp; <br>&nbsp; &nbsp; &nbsp; Writeln(f,chr(27)+chr(ord('J'))+chr($20)); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; &nbsp; &nbsp; flush(f); &nbsp; <br>&nbsp; &nbsp; &nbsp; Closefile(f); &nbsp; <br>&nbsp; &nbsp; <br>&nbsp; end;
 
谢谢参与!虽然没有解决问题.
 
多人接受答案了。
 
后退
顶部