C# 通过Zebra打印机RZ400验证编码标签

C# 通过Zebra打印机RZ400验证编码标签,c#,zpl,C#,Zpl,下面是一个C#函数,它通过串行端口发送ZPL命令。 ZPL命令以~RVE开头(通知打印机发送RFID编码成功或失败结果) 如何在代码上下文中接收编码结果并检查编码过程是否成功 private void Print() { // Command to be sent to the printer string command = "~RVE^XA^RFw,H^FD033B2E3C9FD0803CE8000001^FS ^XZ"; /

下面是一个C#函数,它通过串行端口发送ZPL命令。 ZPL命令以~RVE开头(通知打印机发送RFID编码成功或失败结果)

如何在代码上下文中接收编码结果并检查编码过程是否成功

    private void Print()
    {
        // Command to be sent to the printer
        string command = "~RVE^XA^RFw,H^FD033B2E3C9FD0803CE8000001^FS ^XZ";

        // Create a buffer with the command
        Byte[] buffer = new byte[command.Length];
        buffer = System.Text.Encoding.ASCII.GetBytes(command);
        // Use the CreateFile external func to connect to the LPT1 port
        SafeFileHandle printer = CreateFile("LPT1:", FileAccess.ReadWrite,
        0, IntPtr.Zero, FileMode.Open, 0, IntPtr.Zero);
        // Aqui verifico se a impressora é válida
        if (printer.IsInvalid == true)
        {
            return;
        }

        // Open the filestream to the lpt1 port and send the command
        FileStream lpt1 = new FileStream(printer, FileAccess.ReadWrite);

        Byte[] ResultBuffer = new byte[255];
        lpt1.Write(buffer, 0, buffer.Length);

        // Close the FileStream connection
        lpt1.Close();

    }

您可能无法使用LPT和CreateFile检索结果。 你需要使用

更新: 有一个Input32库可用,它允许双向lpt端口通信


感谢您的快速重播,但我的zebra(RZ 400)打印机不支持网络连接。是否有任何方法可以使用LPT检索结果?更新的答案。我不确定这个图书馆能不能用,它已经过时了。您也可以尝试以与写入数据相同的方式读取数据-打开LPT1文件并从中读取。Zebra RZ400有一个串行端口(您将需要一根空调制解调器电缆)。还可以添加ZebraNet以太网卡。这两种选择都是好的。Zebra在其网站上有一个插座示例: