RSS订阅 | 匿名投稿
您的位置:网站首页 > 硬件 > 正文

Delphi POS – 通过USB Printer打开钱抽屉

作者:admin 来源: 日期:2014/6/9 9:53:48 人气: 标签:POS POS机

procedure USBOpenCashDrawer(PrinterName: String);
var
  // use winspool
  Handle, hDeviceMode: THandle;
  N: DWORD;
  DocInfo1: TDocInfo1;
  Device, Driver, Port: array [0 .. 255] of char;
  ThePrinter: string;
  <a title="code" href="http://superlevin.ifengyuan.tw/tag/code/">code</a>:ansistring;
begin
  ThePrinter := PrinterName;
  Code := chr(27) + chr(64)+ chr(27) + chr(112) + chr(0) + chr(50) + chr(200);
 
  <a title="Printer" href="http://superlevin.ifengyuan.tw/tag/printer/">Printer</a>.PrinterIndex := Printer.Printers.Indexof(ThePrinter);
  Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
  PrinterName := Format('%s', [Device]);
  if not WinSpool.OpenPrinter(PChar(PrinterName), Handle, nil) then
  begin
   // ShowMessage('Error : ' + IntToStr(GetLastError));
    Exit;
  end;
  with DocInfo1 do
  begin
    pDocName := 'Test';
    pOutputFile := nil;
    pDataType := 'RAW';
  end;
 
  WinSpool.StartDocPrinter(Handle, 1, @DocInfo1);
  WinSpool.StartPagePrinter(Handle);
  WinSpool.WritePrinter(Handle, PAnsiChar(Code), Length(Code), N);
  WinSpool.EndPagePrinter(Handle);
  WinSpool.EndDocPrinter(Handle);
  WinSpool.ClosePrinter(Handle);
 
end;

读完这篇文章后,您心情如何?
0
0
0
0
0
0
0
0
本文网址: