精华区 [关闭][返回]

当前位置:网易精华区>>讨论区精华>>编程开发>>● Delphi>>报表和打印>>打印>>在95下能往网络打印机送ESC码吗?

主题:在95下能往网络打印机送ESC码吗?
发信人: yueqs()
整理人: yueqs(2000-12-05 19:17:12), 站内信件
【 在 pazee (耙子) 的大作中提到: 】
: 在95下能往网络打印机送ESC码吗?
: 我发现网络打印机也是一个新端口,
: 我用CreateFile()打开他,
: 用WriteFile()写,但是不能成功,怎么办?
:    .......

这个方式比较标准:

unit Passthru;

interface

uses printers, WinProcs, WinTypes, SysUtils;

Procedure       PrintTest;

implementation

Type
        TPassThroughData = Record
                nLen : Integer;
                Data : Array[0..255] of byte;
        end;

Procedure DirectPrint(s : String);
var
        PTBlock : TPassThroughData;
Begin
        PTBlock.nLen := Length(s);
        StrPCopy(@PTBlock.Data,s);
        Escape(printer.handle, PASSTHROUGH,0,@PTBlock,nil);
End;



Procedure PrintTest;
Begin
        Printer.BeginDoc;
        DirectPrint(CHR(27)+'&l1O'+'Hello, World!');
        Printer.EndDoc;
End;


end.


--
※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 210.78.157.47]

[关闭][返回]