简体   繁体   English

在C#中通过USB发送打印机命令

[英]Sending Printer Commands via USB in C#

I have a ticket printer I am trying to send raw print commands to, 我有一个售票打印机,我试图将原始打印命令发送到

I am currently sending the commands by pinvoke to winspool.drv and calling WritePrinter. 我目前正在通过pinvoke将命令发送到winspool.drv并调用WritePrinter。 This is working for most of the commands I am sending, but I cannot get feedback from the printer this way (for example, the printer has a barcode reader on it, I can send them command read barcode but I cannot receive the data back as it is stopped by the windows spooler). 这适用于我发送的大多数命令,但是我无法以这种方式从打印机获得反馈(例如,打印机上装有条形码读取器,我可以向他们发送命令读取的条形码,但不能以以下方式接收数据: Windows假脱机程序将其停止)。

Is there a way to open a USB port and send a byte[] of commands in C#? 有没有办法打开USB端口并在C#中发送命令的byte []?

Many Thanks 非常感谢

Shaun 肖恩

You can exchange data over USB in a similar manner as you read/write to a file. 您可以通过USB交换数据,就像读取/写入文件一样。 Here's an interesting article on that topic . 这是一篇有关该主题的有趣文章

Using the windows printer driver has some advantages though. 但是,使用Windows打印机驱动程序具有一些优点。 Are you sure you want to do this yourself? 您确定要自己执行此操作吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM