gpt4 book ai didi

delphi - Delphi中将数据发送到USB打印机

转载 作者:行者123 更新时间:2023-12-03 15:09:13 28 4
gpt4 key购买 nike

如何使用 Delphi 将文本命令发送到连接到 USB 端口的打印机?

我有一台 Zebra TLP2844 打印机,想要对其进行直接通信编程。

最佳答案

您使用WinAPI函数Escape ,将 Printer.Canvas.Handle 作为第一个参数传递,并将 PASSTHROUGH 作为 nEscape 参数传递。

var
YourCommand: String;
begin
YourComamnd := 'Your command here';

if Escape(Printer.Canvas.Handle,
PASSTHROUGH,
Length(YourCommand),
PChar(YourCommand),
nil) <> 0 then
// Handle return value (listed in docs link above)
else
// send next command

Escape 是在 Windows 单元中定义的。请注意,在使用此函数之前,您必须调用Printer.StartPage,以便准备打印机驱动程序来接收内容。

关于delphi - Delphi中将数据发送到USB打印机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16949683/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com