type
TOutBufPassThrough = record // 用于USB接口打印机开钱箱 // 调用windows.extEscape可以直接用extEscape(handle, PASSTHROUGH, sizeOf(outBuf), @outBuf, 0, nil)向设备发送esc命令 nDataLen: word; sEscData: array [0 .. 1024] of AnsiChar; end;procedure TFrmCollectionOrder.OpenUSBMoneyBox;
var prt: TPrinter; esc: TOutBufPassThrough; sMoneyBoxOpenCommand: AnsiString;begin try prt := Printers.Printer; prt.beginDoc; sMoneyBoxOpenCommand := AnsiString(const_OpenMoneyBoxCommand); esc.nDataLen := Length(sMoneyBoxOpenCommand); strpCopy(esc.sEscData, sMoneyBoxOpenCommand); Windows.ExtEscape(prt.Handle, PASSTHROUGH, sizeOf(esc), @esc, 0, nil); // PASSTHROUGH:允许程序直接发送数据到设备 prt.endDoc; exceptend;
end;